faster-eth-abi 5.2.15__cp314-cp314t-win32.whl → 5.2.16__cp314-cp314t-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of faster-eth-abi might be problematic. Click here for more details.

Files changed (48) hide show
  1. faster_eth_abi/_codec.cp314t-win32.pyd +0 -0
  2. faster_eth_abi/_codec.py +6 -0
  3. faster_eth_abi/_decoding.cp314t-win32.pyd +0 -0
  4. faster_eth_abi/_decoding.py +28 -15
  5. faster_eth_abi/_encoding.cp314t-win32.pyd +0 -0
  6. faster_eth_abi/_encoding.py +7 -1
  7. faster_eth_abi/_grammar.cp314t-win32.pyd +0 -0
  8. faster_eth_abi/_grammar.py +5 -0
  9. faster_eth_abi/abi.cp314t-win32.pyd +0 -0
  10. faster_eth_abi/base.py +4 -0
  11. faster_eth_abi/codec.py +1261 -144
  12. faster_eth_abi/constants.cp314t-win32.pyd +0 -0
  13. faster_eth_abi/decoding.py +91 -47
  14. faster_eth_abi/encoding.py +51 -3
  15. faster_eth_abi/exceptions.py +5 -2
  16. faster_eth_abi/from_type_str.cp314t-win32.pyd +0 -0
  17. faster_eth_abi/from_type_str.py +4 -0
  18. faster_eth_abi/grammar.py +17 -19
  19. faster_eth_abi/io.py +4 -0
  20. faster_eth_abi/packed.cp314t-win32.pyd +0 -0
  21. faster_eth_abi/packed.py +4 -0
  22. faster_eth_abi/registry.py +98 -33
  23. faster_eth_abi/tools/__init__.cp314t-win32.pyd +0 -0
  24. faster_eth_abi/tools/_strategies.cp314t-win32.pyd +0 -0
  25. faster_eth_abi/typing.py +94 -10
  26. faster_eth_abi/utils/__init__.cp314t-win32.pyd +0 -0
  27. faster_eth_abi/utils/numeric.cp314t-win32.pyd +0 -0
  28. faster_eth_abi/utils/padding.cp314t-win32.pyd +0 -0
  29. faster_eth_abi/utils/string.cp314t-win32.pyd +0 -0
  30. faster_eth_abi/utils/validation.cp314t-win32.pyd +0 -0
  31. {faster_eth_abi-5.2.15.dist-info → faster_eth_abi-5.2.16.dist-info}/METADATA +13 -8
  32. faster_eth_abi-5.2.16.dist-info/RECORD +47 -0
  33. {faster_eth_abi-5.2.15.dist-info → faster_eth_abi-5.2.16.dist-info}/top_level.txt +0 -1
  34. faster_eth_abi__mypyc.cp314t-win32.pyd +0 -0
  35. benchmarks/__init__.py +0 -1
  36. benchmarks/batch.py +0 -9
  37. benchmarks/data.py +0 -313
  38. benchmarks/test_abi_benchmarks.py +0 -82
  39. benchmarks/test_decoding_benchmarks.py +0 -109
  40. benchmarks/test_encoding_benchmarks.py +0 -99
  41. benchmarks/test_grammar_benchmarks.py +0 -38
  42. benchmarks/test_io_benchmarks.py +0 -99
  43. benchmarks/test_packed_benchmarks.py +0 -41
  44. benchmarks/test_registry_benchmarks.py +0 -45
  45. benchmarks/type_strings.py +0 -26
  46. faster_eth_abi-5.2.15.dist-info/RECORD +0 -58
  47. {faster_eth_abi-5.2.15.dist-info → faster_eth_abi-5.2.16.dist-info}/WHEEL +0 -0
  48. {faster_eth_abi-5.2.15.dist-info → faster_eth_abi-5.2.16.dist-info}/licenses/LICENSE +0 -0
benchmarks/data.py DELETED
@@ -1,313 +0,0 @@
1
- # Shared value lists for encoding/decoding/packed/abi benchmarks
2
-
3
- from decimal import (
4
- Decimal,
5
- )
6
-
7
- # Granular lists for encoding/decoding
8
- booleans = [True, False]
9
-
10
- addresses = [
11
- b"\x00" * 19 + b"\x01",
12
- b"\xff" * 20,
13
- b"\x01" * 20,
14
- b"\x00" * 20,
15
- b"\x12" * 20,
16
- b"\x00" * 19 + b"\x02",
17
- b"\x01" * 19 + b"\x00",
18
- ]
19
-
20
- uint256s = [
21
- 0,
22
- 1,
23
- 2**256 - 1,
24
- 2**128,
25
- 2**64,
26
- 12345678901234567890,
27
- 2**255,
28
- 2**255 - 1,
29
- 2**32,
30
- 2**16,
31
- 42,
32
- 999999999999999999999999999999,
33
- ]
34
-
35
- bytes32s = [
36
- b"\x00" * 32,
37
- b"\xff" * 32,
38
- b"abc" * 10 + b"de",
39
- b"\x01" * 32,
40
- b"\x12" * 32,
41
- b"", # empty
42
- b"\x00" * 16, # short
43
- ]
44
-
45
- bytes32_ids = list(map(repr, bytes32s))
46
-
47
- strings = [
48
- "",
49
- "hello world",
50
- "𝔘𝔫𝔦𝔠𝔬𝔡𝔢",
51
- "a" * 256,
52
- "b" * 1024,
53
- "c" * 4096,
54
- "d" * 8192,
55
- "e" * 16384,
56
- "f" * 32768,
57
- "g" * 65536,
58
- "\0", # null byte
59
- "a\nb", # newline
60
- "a" * 100000, # very long
61
- ]
62
-
63
- string_ids = [
64
- "empty",
65
- "hello-world",
66
- "unicode",
67
- "'a' * 256",
68
- "'b' * 1024",
69
- "'c' * 4096",
70
- "'d' * 8192",
71
- "'e' * 16384",
72
- "'f' * 32768",
73
- "'g' * 65536",
74
- "null-byte",
75
- "newline",
76
- "very-long",
77
- ]
78
-
79
- tuples = [
80
- ((1, True), ["uint256", "bool"]),
81
- ((b"\x00" * 32, "foo"), ["bytes32", "string"]),
82
- ((2**255 - 1, False, "bar"), ["int256", "bool", "string"]),
83
- (([1, 2, 3], [True, False]), ["uint8[3]", "bool[2]"]),
84
- ((b"\x01" * 20, 0), ["address", "uint8"]),
85
- (([b"\x00" * 32, b"\xff" * 32], ["a", "b"]), ["bytes32[2]", "string[2]"]),
86
- ]
87
- tuple_ids = [
88
- "int-bool",
89
- "bytes-string",
90
- "int-bool-string",
91
- "arrs",
92
- "addr-uint8",
93
- "bytes32s-strings",
94
- ]
95
-
96
- # --- Comprehensive ABI test cases for abi/packed benchmarks ---
97
-
98
-
99
- # Primitive types
100
- def make_fixed_decimal(bits: int, exp: int) -> Decimal:
101
- # For each (bits, exp), generate a value within the allowed range
102
- # Range: [-2**(bits-1)/10**exp, 2**(bits-1)-1/10**exp]
103
- max_val = (2 ** (bits - 1) - 1) / (10**exp)
104
- min_val = -(2 ** (bits - 1)) / (10**exp)
105
- # Use a value safely within the range, e.g., 1.2 or 0.1 if possible
106
- if max_val >= 1.2 and min_val <= -1.2:
107
- return Decimal("1.2").quantize(Decimal("1." + "0" * exp))
108
- elif max_val >= 0.1:
109
- return Decimal("0.1").quantize(Decimal("1." + "0" * exp))
110
- else:
111
- return Decimal(str(max_val)).quantize(Decimal("1." + "0" * exp))
112
-
113
-
114
- def make_ufixed_decimal(bits: int, exp: int) -> Decimal:
115
- # For each (bits, exp), generate a value within the allowed range
116
- # Range: [0, 2**bits-1/10**exp]
117
- max_val = (2**bits - 1) / (10**exp)
118
- if max_val >= 1.2:
119
- return Decimal("1.2").quantize(Decimal("1." + "0" * exp))
120
- elif max_val >= 0.1:
121
- return Decimal("0.1").quantize(Decimal("1." + "0" * exp))
122
- else:
123
- return Decimal(str(max_val)).quantize(Decimal("1." + "0" * exp))
124
-
125
-
126
- decimal_cases = []
127
- for bits in (8, 16, 32, 64, 128, 256):
128
- for exp in (1, 2, 10, 18, 80):
129
- max_val_fixed = (2 ** (bits - 1) - 1) / (10**exp)
130
- if max_val_fixed >= 1.0:
131
- decimal_cases.append((f"fixed{bits}x{exp}", make_fixed_decimal(bits, exp)))
132
- max_val_ufixed = (2**bits - 1) / (10**exp)
133
- if max_val_ufixed >= 1.0:
134
- decimal_cases.append(
135
- (f"ufixed{bits}x{exp}", make_ufixed_decimal(bits, exp))
136
- )
137
-
138
- primitive_cases = (
139
- [
140
- ("uint8", 0),
141
- ("uint8", 255),
142
- ("uint16", 65535),
143
- ("uint32", 2**32 - 1),
144
- ("uint64", 2**64 - 1),
145
- ("uint128", 2**128 - 1),
146
- ("uint256", 0),
147
- ("uint256", 2**256 - 1),
148
- ("int8", -128),
149
- ("int8", 127),
150
- ("int16", -32768),
151
- ("int16", 32767),
152
- ("int32", -(2**31)),
153
- ("int32", 2**31 - 1),
154
- ("int64", -(2**63)),
155
- ("int64", 2**63 - 1),
156
- ("int128", -(2**127)),
157
- ("int128", 2**127 - 1),
158
- ("int256", -(2**255)),
159
- ("int256", 2**255 - 1),
160
- ("bool", True),
161
- ("bool", False),
162
- ("address", b"\x00" * 19 + b"\x01"),
163
- ("address", b"\xff" * 20),
164
- ("bytes1", b"\x01"),
165
- ]
166
- + [(f"bytes{M}", b"\x01" * M) for M in range(2, 33)]
167
- + [
168
- ("bytes", b""),
169
- ("bytes", b"hello world"),
170
- ("bytes", b"\x00" * 100),
171
- ("bytes", b"a" * 256),
172
- ("string", ""),
173
- ("string", "hello world"),
174
- ("string", "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"),
175
- ("string", "a" * 256),
176
- ("string", "b" * 1024),
177
- ]
178
- + decimal_cases
179
- + [
180
- ("function", b"\x01" * 24),
181
- ("function", b"\x00" * 24),
182
- ("function", b"\xff" * 24),
183
- ]
184
- )
185
- primitive_ids = [f"{t}-{repr(v)[:16]}" for t, v in primitive_cases]
186
-
187
- # Arrays
188
- array_cases = [
189
- ("uint8[3]", [1, 2, 3]),
190
- ("uint256[2]", [0, 2**256 - 1]),
191
- ("bool[4]", [True, False, True, False]),
192
- ("address[2]", [b"\x00" * 19 + b"\x01", b"\xff" * 20]),
193
- ("bytes32[2]", [b"\x00" * 32, b"\xff" * 32]),
194
- ("string[2]", ["foo", "bar"]),
195
- ("uint8[]", [1, 2, 3, 4, 5]),
196
- ("string[]", ["a", "b", "c"]),
197
- ("bytes[]", [b"abc", b"def", b"ghi"]),
198
- ("uint256[2][2]", [[1, 2], [3, 4]]),
199
- ("bool[][2]", [[True, False], [False, True]]),
200
- ("bytes8[4]", [b"\x01" * 8, b"\x02" * 8, b"\x03" * 8, b"\x04" * 8]),
201
- ("fixed32x2[2]", [Decimal("3.14"), Decimal("2.71")]),
202
- ("uint8[]", []),
203
- ("bytes[]", []),
204
- ("fixed32x2[]", []),
205
- ("uint8[10]", list(range(10))),
206
- ("string[5]", ["a", "b", "c", "d", "e"]),
207
- ("bytes16[3]", [b"\x01" * 16, b"\x02" * 16, b"\x03" * 16]),
208
- ("uint8[100]", list(range(100))),
209
- ("string[10]", list(map(str, range(10)))),
210
- ("bytes[10]", list(map(lambda i: i.to_bytes(8, "little"), range(10)))),
211
- ("uint8[][]", [[]]),
212
- ("string[]", []),
213
- ("uint8[2][]", []),
214
- ("uint8[2][2][]", []),
215
- ]
216
- array_ids = [f"{t}-{repr(v)[:16]}" for t, v in array_cases]
217
-
218
- # Tuples
219
- tuple_cases = [
220
- ("(uint256,bool)", (42, True)),
221
- ("(address,uint8)", (b"\x00" * 19 + b"\x01", 255)),
222
- ("(string,bytes)", ("foo", b"bar")),
223
- ("(uint256[2],string)", ([1, 2], "baz")),
224
- ("(uint8,(bool,string))", (7, (False, "hi"))),
225
- ("((uint8,uint8),uint8)", ((1, 2), 3)),
226
- ("(uint8[2],(string,bool[2]))", ([1, 2], ("x", [True, False]))),
227
- ("(fixed32x2,uint8)", (Decimal("3.14"), 255)),
228
- (
229
- "(bytes1,bytes2,bytes3,bytes4)",
230
- (b"\x01", b"\x01\x02", b"\x01\x02\x03", b"\x01\x02\x03\x04"),
231
- ),
232
- ("(function,uint256)", (b"\x01" * 24, 123)),
233
- ("(uint8[3],(string[2],bool[2]))", ([1, 2, 3], (["a", "b"], [True, False]))),
234
- ("(bytes32[],string[])", ([b"\x00" * 32, b"\xff" * 32], ["foo", "bar"])),
235
- ]
236
- tuple_ids_full = [f"{t}-{repr(v)[:16]}" for t, v in tuple_cases]
237
-
238
- # Nested/complex
239
- nested_cases = [
240
- ("(uint256[],(string[],bool))", ([1, 2, 3], (["a", "b"], True))),
241
- ("((uint8[2],(string,bool)),bytes32)", (([1, 2], ("hi", False)), b"\x00" * 32)),
242
- (
243
- "(uint8[2][2],(string[2],bool[2]))",
244
- ([[1, 2], [3, 4]], (["x", "y"], [True, False])),
245
- ),
246
- ("(uint8[2][2][2],string)", ([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], "deep")),
247
- (
248
- "((uint8[2][2],(string[2],bool[2])),bytes32[2])",
249
- (([[1, 2], [3, 4]], (["x", "y"], [True, False])), [b"\x00" * 32, b"\xff" * 32]),
250
- ),
251
- (
252
- "(uint8[2][2][2][2],string[2])",
253
- (
254
- [
255
- [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],
256
- [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],
257
- ],
258
- ["deep", "deeper"],
259
- ),
260
- ),
261
- (
262
- "(uint8[2][2][2][2][2],string[2][2])",
263
- (
264
- [
265
- [
266
- [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],
267
- [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],
268
- ],
269
- [
270
- [[[17, 18], [19, 20]], [[21, 22], [23, 24]]],
271
- [[[25, 26], [27, 28]], [[29, 30], [31, 32]]],
272
- ],
273
- ],
274
- [["a", "b"], ["c", "d"]],
275
- ),
276
- ),
277
- ]
278
- nested_ids = [f"{t}-{repr(v)[:16]}" for t, v in nested_cases]
279
-
280
- # Edge cases
281
- edge_cases = [
282
- ("uint8[]", []),
283
- ("string[]", []),
284
- ("bytes", b"\x00" * 1024),
285
- ("string", "a" * 1024),
286
- ("(uint8[],string)", ([], "")),
287
- ("(string[],bytes[])", ([""], [b""])),
288
- ("bytes[]", []),
289
- ("fixed32x2[]", []),
290
- ("(uint8[][],string)", ([[]], "")),
291
- ("(string[],bytes[])", ([], [])),
292
- ("(uint8[2][],string[])", ([], [])),
293
- ("(uint8[2][2][],string[])", ([], [])),
294
- ("bytes[100]", list(map(lambda i: i.to_bytes(32, "little"), range(100)))),
295
- ("(bytes[],string[])", ([], [])),
296
- ("(uint8[2][2][2][2][],string[])", ([], [])),
297
- ]
298
- edge_ids = [f"{t}-{repr(v)[:16]}" for t, v in edge_cases]
299
-
300
- # Combine all cases
301
- all_cases = primitive_cases + array_cases + tuple_cases + nested_cases + edge_cases
302
- all_ids = primitive_ids + array_ids + tuple_ids_full + nested_ids + edge_ids
303
-
304
- # Packed-compatible subset (for test_packed_benchmarks.py)
305
- packed_cases = [
306
- ("uint256", 123456789),
307
- ("address", b"\x00" * 19 + b"\x01"),
308
- ("bytes", b"hello world"),
309
- ("bool", True),
310
- ("string", "hello world"),
311
- ("(uint256,bool)", (42, False)),
312
- ]
313
- packed_ids = ["uint256", "address", "bytes", "bool", "string", "tuple"]
@@ -1,82 +0,0 @@
1
- import pytest
2
-
3
- import eth_abi
4
- from pytest_codspeed import (
5
- BenchmarkFixture,
6
- )
7
-
8
- from benchmarks.batch import (
9
- batch,
10
- )
11
- from benchmarks.data import (
12
- all_cases,
13
- all_ids,
14
- )
15
- import faster_eth_abi
16
-
17
- # --- ENCODE ---
18
-
19
-
20
- @pytest.mark.benchmark(group="encode")
21
- @pytest.mark.parametrize("abi_type,value", all_cases, ids=all_ids)
22
- def test_encode(benchmark: BenchmarkFixture, abi_type, value):
23
- benchmark(batch, 100, eth_abi.encode, [abi_type], [value])
24
-
25
-
26
- @pytest.mark.benchmark(group="encode")
27
- @pytest.mark.parametrize("abi_type,value", all_cases, ids=all_ids)
28
- def test_faster_encode(benchmark: BenchmarkFixture, abi_type, value):
29
- benchmark(batch, 100, faster_eth_abi.encode, [abi_type], [value])
30
-
31
-
32
- # --- DECODE ---
33
-
34
- decode_cases = [
35
- (abi_type, faster_eth_abi.encode([abi_type], [value]))
36
- for abi_type, value in all_cases
37
- ]
38
- decode_ids = all_ids
39
-
40
-
41
- @pytest.mark.benchmark(group="decode")
42
- @pytest.mark.parametrize("abi_type,encoded", decode_cases, ids=decode_ids)
43
- def test_decode(benchmark: BenchmarkFixture, abi_type, encoded):
44
- benchmark(batch, 100, eth_abi.decode, [abi_type], encoded)
45
-
46
-
47
- @pytest.mark.benchmark(group="decode")
48
- @pytest.mark.parametrize("abi_type,encoded", decode_cases, ids=decode_ids)
49
- def test_faster_decode(benchmark: BenchmarkFixture, abi_type, encoded):
50
- benchmark(batch, 100, faster_eth_abi.decode, [abi_type], encoded)
51
-
52
-
53
- # --- IS_ENCODABLE ---
54
-
55
-
56
- @pytest.mark.benchmark(group="is_encodable")
57
- @pytest.mark.parametrize("abi_type,value", all_cases, ids=all_ids)
58
- def test_is_encodable(benchmark: BenchmarkFixture, abi_type, value):
59
- benchmark(batch, 100, eth_abi.is_encodable, abi_type, value)
60
-
61
-
62
- @pytest.mark.benchmark(group="is_encodable")
63
- @pytest.mark.parametrize("abi_type,value", all_cases, ids=all_ids)
64
- def test_faster_is_encodable(benchmark: BenchmarkFixture, abi_type, value):
65
- benchmark(batch, 100, faster_eth_abi.is_encodable, abi_type, value)
66
-
67
-
68
- # --- IS_ENCODABLE_TYPE ---
69
-
70
- all_types = list({abi_type for abi_type, _ in all_cases})
71
-
72
-
73
- @pytest.mark.benchmark(group="is_encodable_type")
74
- @pytest.mark.parametrize("abi_type", all_types, ids=all_types)
75
- def test_is_encodable_type(benchmark: BenchmarkFixture, abi_type):
76
- benchmark(batch, 100, eth_abi.is_encodable_type, abi_type)
77
-
78
-
79
- @pytest.mark.benchmark(group="is_encodable_type")
80
- @pytest.mark.parametrize("abi_type", all_types, ids=all_types)
81
- def test_faster_is_encodable_type(benchmark: BenchmarkFixture, abi_type):
82
- benchmark(batch, 100, faster_eth_abi.is_encodable_type, abi_type)
@@ -1,109 +0,0 @@
1
- import pytest
2
-
3
- import eth_abi
4
- from pytest_codspeed import (
5
- BenchmarkFixture,
6
- )
7
-
8
- from benchmarks.batch import (
9
- batch,
10
- )
11
- from benchmarks.data import (
12
- addresses,
13
- booleans,
14
- bytes32_ids,
15
- bytes32s,
16
- string_ids,
17
- strings,
18
- tuple_ids,
19
- tuples,
20
- uint256s,
21
- )
22
- import faster_eth_abi
23
-
24
- booleans_encoded = [faster_eth_abi.encode(["bool"], [v]) for v in booleans]
25
- addresses_encoded = [faster_eth_abi.encode(["address"], [v]) for v in addresses]
26
- uint256s_encoded = [faster_eth_abi.encode(["uint256"], [v]) for v in uint256s]
27
- bytes32s_encoded = [faster_eth_abi.encode(["bytes32"], [v]) for v in bytes32s]
28
- strings_encoded = [faster_eth_abi.encode(["string"], [v]) for v in strings]
29
- tuples_encoded = [
30
- (faster_eth_abi.encode(types, list(values)), types) for values, types in tuples
31
- ]
32
-
33
-
34
- # Boolean decoding
35
- @pytest.mark.benchmark(group="BooleanDecoder")
36
- @pytest.mark.parametrize("value", booleans_encoded, ids=booleans)
37
- def test_boolean_decoder(benchmark: BenchmarkFixture, value):
38
- benchmark(batch, 100, eth_abi.decode, ["bool"], value)
39
-
40
-
41
- @pytest.mark.benchmark(group="BooleanDecoder")
42
- @pytest.mark.parametrize("value", booleans_encoded, ids=booleans)
43
- def test_faster_boolean_decoder(benchmark: BenchmarkFixture, value):
44
- benchmark(batch, 100, faster_eth_abi.decode, ["bool"], value)
45
-
46
-
47
- # Address decoding
48
- @pytest.mark.benchmark(group="AddressDecoder")
49
- @pytest.mark.parametrize("value", addresses_encoded, ids=addresses)
50
- def test_address_decoder(benchmark: BenchmarkFixture, value):
51
- benchmark(batch, 100, eth_abi.decode, ["address"], value)
52
-
53
-
54
- @pytest.mark.benchmark(group="AddressDecoder")
55
- @pytest.mark.parametrize("value", addresses_encoded, ids=addresses)
56
- def test_faster_address_decoder(benchmark: BenchmarkFixture, value):
57
- benchmark(batch, 100, faster_eth_abi.decode, ["address"], value)
58
-
59
-
60
- # Unsigned integer decoding
61
- @pytest.mark.benchmark(group="UnsignedIntegerDecoder")
62
- @pytest.mark.parametrize("value", uint256s_encoded, ids=uint256s)
63
- def test_uint256_decoder(benchmark: BenchmarkFixture, value):
64
- benchmark(batch, 100, eth_abi.decode, ["uint256"], value)
65
-
66
-
67
- @pytest.mark.benchmark(group="UnsignedIntegerDecoder")
68
- @pytest.mark.parametrize("value", uint256s_encoded, ids=uint256s)
69
- def test_faster_uint256_decoder(benchmark: BenchmarkFixture, value):
70
- benchmark(batch, 100, faster_eth_abi.decode, ["uint256"], value)
71
-
72
-
73
- # Bytes decoding
74
- @pytest.mark.benchmark(group="BytesDecoder")
75
- @pytest.mark.parametrize("value", bytes32s_encoded, ids=bytes32_ids)
76
- def test_bytes32_decoder(benchmark: BenchmarkFixture, value):
77
- benchmark(batch, 100, eth_abi.decode, ["bytes32"], value)
78
-
79
-
80
- @pytest.mark.benchmark(group="BytesDecoder")
81
- @pytest.mark.parametrize("value", bytes32s_encoded, ids=bytes32_ids)
82
- def test_faster_bytes32_decoder(benchmark: BenchmarkFixture, value):
83
- benchmark(batch, 100, faster_eth_abi.decode, ["bytes32"], value)
84
-
85
-
86
- # String decoding
87
- @pytest.mark.benchmark(group="TextStringDecoder")
88
- @pytest.mark.parametrize("value", strings_encoded, ids=string_ids)
89
- def test_string_decoder(benchmark: BenchmarkFixture, value):
90
- benchmark(batch, 100, eth_abi.decode, ["string"], value)
91
-
92
-
93
- @pytest.mark.benchmark(group="TextStringDecoder")
94
- @pytest.mark.parametrize("value", strings_encoded, ids=string_ids)
95
- def test_faster_string_decoder(benchmark: BenchmarkFixture, value):
96
- benchmark(batch, 100, faster_eth_abi.decode, ["string"], value)
97
-
98
-
99
- # Tuple decoding
100
- @pytest.mark.benchmark(group="TupleDecoder")
101
- @pytest.mark.parametrize("value,types", tuples_encoded, ids=tuple_ids)
102
- def test_tuple_decoder(benchmark: BenchmarkFixture, value, types):
103
- benchmark(batch, 100, eth_abi.decode, types, value)
104
-
105
-
106
- @pytest.mark.benchmark(group="TupleDecoder")
107
- @pytest.mark.parametrize("value,types", tuples_encoded, ids=tuple_ids)
108
- def test_faster_tuple_decoder(benchmark: BenchmarkFixture, value, types):
109
- benchmark(batch, 100, faster_eth_abi.decode, types, value)
@@ -1,99 +0,0 @@
1
- import pytest
2
-
3
- import eth_abi
4
- from pytest_codspeed import (
5
- BenchmarkFixture,
6
- )
7
-
8
- from benchmarks.batch import (
9
- batch,
10
- )
11
- from benchmarks.data import (
12
- addresses,
13
- booleans,
14
- bytes32s,
15
- string_ids,
16
- strings,
17
- tuple_ids,
18
- tuples,
19
- uint256s,
20
- )
21
- import faster_eth_abi
22
-
23
-
24
- # Boolean encoding
25
- @pytest.mark.benchmark(group="BooleanEncoder")
26
- @pytest.mark.parametrize("value", booleans)
27
- def test_boolean_encoder(benchmark: BenchmarkFixture, value):
28
- benchmark(batch, 100, eth_abi.encode, ["bool"], [value])
29
-
30
-
31
- @pytest.mark.benchmark(group="BooleanEncoder")
32
- @pytest.mark.parametrize("value", booleans)
33
- def test_faster_boolean_encoder(benchmark: BenchmarkFixture, value):
34
- benchmark(batch, 100, faster_eth_abi.encode, ["bool"], [value])
35
-
36
-
37
- # Address encoding
38
- @pytest.mark.benchmark(group="AddressEncoder")
39
- @pytest.mark.parametrize("value", addresses)
40
- def test_address_encoder(benchmark: BenchmarkFixture, value):
41
- benchmark(batch, 100, eth_abi.encode, ["address"], [value])
42
-
43
-
44
- @pytest.mark.benchmark(group="AddressEncoder")
45
- @pytest.mark.parametrize("value", addresses)
46
- def test_faster_address_encoder(benchmark: BenchmarkFixture, value):
47
- benchmark(batch, 100, faster_eth_abi.encode, ["address"], [value])
48
-
49
-
50
- # Unsigned integer encoding
51
- @pytest.mark.benchmark(group="UnsignedIntegerEncoder")
52
- @pytest.mark.parametrize("value", uint256s)
53
- def test_uint256_encoder(benchmark: BenchmarkFixture, value):
54
- benchmark(batch, 100, eth_abi.encode, ["uint256"], [value])
55
-
56
-
57
- @pytest.mark.benchmark(group="UnsignedIntegerEncoder")
58
- @pytest.mark.parametrize("value", uint256s)
59
- def test_faster_uint256_encoder(benchmark: BenchmarkFixture, value):
60
- benchmark(batch, 100, faster_eth_abi.encode, ["uint256"], [value])
61
-
62
-
63
- # Bytes encoding
64
- @pytest.mark.benchmark(group="BytesEncoder")
65
- @pytest.mark.parametrize("value", bytes32s)
66
- def test_bytes32_encoder(benchmark: BenchmarkFixture, value):
67
- benchmark(batch, 100, eth_abi.encode, ["bytes32"], [value])
68
-
69
-
70
- @pytest.mark.benchmark(group="BytesEncoder")
71
- @pytest.mark.parametrize("value", bytes32s)
72
- def test_faster_bytes32_encoder(benchmark: BenchmarkFixture, value):
73
- benchmark(batch, 100, faster_eth_abi.encode, ["bytes32"], [value])
74
-
75
-
76
- # String encoding
77
- @pytest.mark.benchmark(group="TextStringEncoder")
78
- @pytest.mark.parametrize("value", strings, ids=string_ids)
79
- def test_string_encoder(benchmark: BenchmarkFixture, value):
80
- benchmark(batch, 100, eth_abi.encode, ["string"], [value])
81
-
82
-
83
- @pytest.mark.benchmark(group="TextStringEncoder")
84
- @pytest.mark.parametrize("value", strings, ids=string_ids)
85
- def test_faster_string_encoder(benchmark: BenchmarkFixture, value):
86
- benchmark(batch, 100, faster_eth_abi.encode, ["string"], [value])
87
-
88
-
89
- # Tuple encoding
90
- @pytest.mark.benchmark(group="TupleEncoder")
91
- @pytest.mark.parametrize("values,types", tuples, ids=tuple_ids)
92
- def test_tuple_encoder(benchmark: BenchmarkFixture, values, types):
93
- benchmark(batch, 100, eth_abi.encode, types, list(values))
94
-
95
-
96
- @pytest.mark.benchmark(group="TupleEncoder")
97
- @pytest.mark.parametrize("values,types", tuples, ids=tuple_ids)
98
- def test_faster_tuple_encoder(benchmark: BenchmarkFixture, values, types):
99
- benchmark(batch, 100, faster_eth_abi.encode, types, list(values))
@@ -1,38 +0,0 @@
1
- import pytest
2
-
3
- import eth_abi.grammar
4
- from pytest_codspeed import (
5
- BenchmarkFixture,
6
- )
7
-
8
- from benchmarks.batch import (
9
- batch,
10
- )
11
- from benchmarks.type_strings import (
12
- type_strings,
13
- )
14
- import faster_eth_abi.grammar
15
-
16
-
17
- @pytest.mark.benchmark(group="GrammarNormalize")
18
- @pytest.mark.parametrize("type_str", type_strings)
19
- def test_normalize(benchmark: BenchmarkFixture, type_str):
20
- benchmark(batch, 5000, eth_abi.grammar.normalize, type_str)
21
-
22
-
23
- @pytest.mark.benchmark(group="GrammarNormalize")
24
- @pytest.mark.parametrize("type_str", type_strings)
25
- def test_faster_normalize(benchmark: BenchmarkFixture, type_str):
26
- benchmark(batch, 5000, faster_eth_abi.grammar.normalize, type_str)
27
-
28
-
29
- @pytest.mark.benchmark(group="GrammarParse")
30
- @pytest.mark.parametrize("type_str", type_strings)
31
- def test_parse(benchmark: BenchmarkFixture, type_str):
32
- benchmark(batch, 5000, eth_abi.grammar.parse, type_str)
33
-
34
-
35
- @pytest.mark.benchmark(group="GrammarParse")
36
- @pytest.mark.parametrize("type_str", type_strings)
37
- def test_faster_parse(benchmark: BenchmarkFixture, type_str):
38
- benchmark(batch, 5000, faster_eth_abi.grammar.parse, type_str)