faster-eth-abi 5.2.14__cp38-cp38-win_amd64.whl → 5.2.16__cp38-cp38-win_amd64.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. 29859a9e7da9d19bb98c__mypyc.cp38-win_amd64.pyd +0 -0
  2. faster_eth_abi/_codec.cp38-win_amd64.pyd +0 -0
  3. faster_eth_abi/_codec.py +6 -0
  4. faster_eth_abi/_decoding.cp38-win_amd64.pyd +0 -0
  5. faster_eth_abi/_decoding.py +28 -15
  6. faster_eth_abi/_encoding.cp38-win_amd64.pyd +0 -0
  7. faster_eth_abi/_encoding.py +7 -1
  8. faster_eth_abi/_grammar.cp38-win_amd64.pyd +0 -0
  9. faster_eth_abi/_grammar.py +14 -3
  10. faster_eth_abi/abi.cp38-win_amd64.pyd +0 -0
  11. faster_eth_abi/base.py +4 -0
  12. faster_eth_abi/codec.py +2668 -1
  13. faster_eth_abi/constants.cp38-win_amd64.pyd +0 -0
  14. faster_eth_abi/decoding.py +91 -47
  15. faster_eth_abi/encoding.py +51 -3
  16. faster_eth_abi/exceptions.py +5 -2
  17. faster_eth_abi/from_type_str.cp38-win_amd64.pyd +0 -0
  18. faster_eth_abi/from_type_str.py +4 -0
  19. faster_eth_abi/grammar.py +17 -19
  20. faster_eth_abi/io.py +4 -0
  21. faster_eth_abi/packed.cp38-win_amd64.pyd +0 -0
  22. faster_eth_abi/packed.py +4 -0
  23. faster_eth_abi/registry.py +98 -33
  24. faster_eth_abi/tools/__init__.cp38-win_amd64.pyd +0 -0
  25. faster_eth_abi/tools/_strategies.cp38-win_amd64.pyd +0 -0
  26. faster_eth_abi/typing.py +4627 -0
  27. faster_eth_abi/utils/__init__.cp38-win_amd64.pyd +0 -0
  28. faster_eth_abi/utils/numeric.cp38-win_amd64.pyd +0 -0
  29. faster_eth_abi/utils/padding.cp38-win_amd64.pyd +0 -0
  30. faster_eth_abi/utils/string.cp38-win_amd64.pyd +0 -0
  31. faster_eth_abi/utils/validation.cp38-win_amd64.pyd +0 -0
  32. {faster_eth_abi-5.2.14.dist-info → faster_eth_abi-5.2.16.dist-info}/METADATA +14 -10
  33. faster_eth_abi-5.2.16.dist-info/RECORD +47 -0
  34. {faster_eth_abi-5.2.14.dist-info → faster_eth_abi-5.2.16.dist-info}/top_level.txt +0 -1
  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.14.dist-info/RECORD +0 -57
  47. {faster_eth_abi-5.2.14.dist-info → faster_eth_abi-5.2.16.dist-info}/LICENSE +0 -0
  48. {faster_eth_abi-5.2.14.dist-info → faster_eth_abi-5.2.16.dist-info}/WHEEL +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: faster_eth_abi
3
- Version: 5.2.14
4
- Summary: A faster fork of eth_abi: Python utilities for working with Ethereum ABI definitions, especially encoding and decoding. Implemented in C.
3
+ Version: 5.2.16
4
+ Summary: A ~2-6x faster fork of eth_abi: Python utilities for working with Ethereum ABI definitions, especially encoding and decoding. Implemented in C.
5
5
  Home-page: https://github.com/BobTheBuidler/faster-eth-abi
6
6
  Author: The Ethereum Foundation
7
7
  Author-email: snakecharmers@ethereum.org
@@ -32,20 +32,21 @@ Requires-Python: >=3.8, <4
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Requires-Dist: cchecksum<0.4,>=0.2.6
35
- Requires-Dist: faster-eth-utils>=2.0.0
36
- Requires-Dist: eth-abi<6,>=5.0.1
37
- Requires-Dist: eth-typing>=3.0.0
35
+ Requires-Dist: faster-eth-utils==5.3.16
36
+ Requires-Dist: eth-abi==5.2.0
37
+ Requires-Dist: eth-typing==5.2.1
38
38
  Requires-Dist: mypy-extensions
39
39
  Requires-Dist: parsimonious<0.11.0,>=0.10.0
40
40
  Provides-Extra: codspeed
41
41
  Requires-Dist: pytest>=7.0.0; extra == "codspeed"
42
- Requires-Dist: pytest-codspeed; extra == "codspeed"
42
+ Requires-Dist: pytest-codspeed<4.3,>=4.2; extra == "codspeed"
43
43
  Requires-Dist: pytest-test-groups; extra == "codspeed"
44
44
  Provides-Extra: dev
45
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "dev"
46
+ Requires-Dist: tqdm; extra == "dev"
45
47
  Requires-Dist: build>=0.9.0; extra == "dev"
46
48
  Requires-Dist: bump-my-version>=0.19.0; extra == "dev"
47
49
  Requires-Dist: ipython; extra == "dev"
48
- Requires-Dist: mypy==1.14.1; extra == "dev"
49
50
  Requires-Dist: pre-commit>=3.4.0; extra == "dev"
50
51
  Requires-Dist: tox>=4.0.0; extra == "dev"
51
52
  Requires-Dist: twine; extra == "dev"
@@ -54,7 +55,7 @@ Requires-Dist: pytest-benchmark; extra == "dev"
54
55
  Requires-Dist: sphinx>=6.0.0; extra == "dev"
55
56
  Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "dev"
56
57
  Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "dev"
57
- Requires-Dist: towncrier<26,>=25; extra == "dev"
58
+ Requires-Dist: towncrier<26,>=24; extra == "dev"
58
59
  Requires-Dist: pytest>=7.0.0; extra == "dev"
59
60
  Requires-Dist: pytest-timeout>=2.0.0; extra == "dev"
60
61
  Requires-Dist: pytest-xdist>=2.4.0; extra == "dev"
@@ -65,7 +66,10 @@ Provides-Extra: docs
65
66
  Requires-Dist: sphinx>=6.0.0; extra == "docs"
66
67
  Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "docs"
67
68
  Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
68
- Requires-Dist: towncrier<26,>=25; extra == "docs"
69
+ Requires-Dist: towncrier<26,>=24; extra == "docs"
70
+ Provides-Extra: mypy
71
+ Requires-Dist: mypy<1.18.3,>=1.14.1; extra == "mypy"
72
+ Requires-Dist: tqdm; extra == "mypy"
69
73
  Provides-Extra: test
70
74
  Requires-Dist: pytest>=7.0.0; extra == "test"
71
75
  Requires-Dist: pytest-timeout>=2.0.0; extra == "test"
@@ -76,7 +80,7 @@ Requires-Dist: hypothesis<6.108.7,>=6.22.0; extra == "test"
76
80
  Provides-Extra: tools
77
81
  Requires-Dist: hypothesis<6.108.7,>=6.22.0; extra == "tools"
78
82
 
79
- ### I forked eth-abi and compiled it to C. It does the same stuff, now faster
83
+ ### I forked eth-abi, added comprehensive type annotations, and compiled it to C. It does the same stuff, now ~2-6x faster.
80
84
 
81
85
  [![PyPI](https://img.shields.io/pypi/v/faster-eth-abi.svg?logo=Python&logoColor=white)](https://pypi.org/project/faster-eth-abi/)
82
86
  [![Monthly Downloads](https://img.shields.io/pypi/dm/faster-eth-abi)](https://pypistats.org/packages/faster-eth-abi)
@@ -0,0 +1,47 @@
1
+ 29859a9e7da9d19bb98c__mypyc.cp38-win_amd64.pyd,sha256=5UDYiea8egYtdi6P0RxruqztOVDpfruyNZRnWJOZiN4,239616
2
+ faster_eth_abi/__init__.py,sha256=JpTfPTiusUGMmX8sEsGAxvILxFbvhh3MEyfiKOd5o9g,217
3
+ faster_eth_abi/_codec.cp38-win_amd64.pyd,sha256=wmCBnG6t9ofPUrDxlSVSq7HuDcSWnsELFOykK8wXHhI,10752
4
+ faster_eth_abi/_codec.py,sha256=hmNYkM1dRFyF97x6cA0Pg26EndRVX7KdwauK67IcUh8,2597
5
+ faster_eth_abi/_decoding.cp38-win_amd64.pyd,sha256=1zik_d3qLgEblUZ2cjIlCQJgQwEvaWD1y0GRc8ZZLlk,10752
6
+ faster_eth_abi/_decoding.py,sha256=zkwnU76AimlbztaJZSewSMJZQld6Si9qAJtssdjYLsM,10244
7
+ faster_eth_abi/_encoding.cp38-win_amd64.pyd,sha256=7FhqBb0Kh_gqST8cEEQKE7V1n394FIWMNc-A4qqC6K8,10752
8
+ faster_eth_abi/_encoding.py,sha256=hAgf9ZUaD05dKpMbUifjWeaE-EXsbuXWOxdrtyoJgUU,9019
9
+ faster_eth_abi/_grammar.cp38-win_amd64.pyd,sha256=P_lB_hlJw9ba4nRQeUIS7Lt-_QdINsDhF5bzxdCbZzw,10752
10
+ faster_eth_abi/_grammar.py,sha256=Gpjf_v5W21JYL0dPfds9XYtzRbftVAkdVeKVV08q2Hs,10926
11
+ faster_eth_abi/abi.cp38-win_amd64.pyd,sha256=Ehid_NQ_F7Uc7v0-xqg-gCe6CDNkaoFLd_3TzJ-5gfU,10752
12
+ faster_eth_abi/abi.py,sha256=-t9OVBSCxy6SuWpCu3cxHrCqkx8_svPIRb0MSFXEl5Q,383
13
+ faster_eth_abi/base.py,sha256=AuuTt9u3OQf8H5_KsCUYIKu5OJyuKw5EbbzxqJ1gyIk,1374
14
+ faster_eth_abi/codec.py,sha256=K5PQ1XpSuhT3VzEoEsdHDpsv7NEcY1u_EdT2XFF9EW0,69433
15
+ faster_eth_abi/constants.cp38-win_amd64.pyd,sha256=0qel9PLERLrYFK0iGxdJh6GGPZc_RxR6ds9jAdkZfEE,10752
16
+ faster_eth_abi/constants.py,sha256=q3FGynS-Eb78cnrL6mBoAvTDz16PF3tW2OylTMd6ajs,114
17
+ faster_eth_abi/decoding.py,sha256=tMqQ-jLrX75Y4CJTqCI5dQ8TFj7JCYOfzFJt3zIsJKo,18178
18
+ faster_eth_abi/encoding.py,sha256=3nLAVBC0MRR0Dmno3CjaygZG-T_ah3-xc0SuJUSNBDc,21998
19
+ faster_eth_abi/exceptions.py,sha256=wWsJJc_ip62fUVI_7CPlR-o37JWfv__ubYprEW0ZcYI,3773
20
+ faster_eth_abi/from_type_str.cp38-win_amd64.pyd,sha256=KzIBz1OqLHlaTSZ4nrC067Ia3tH24cgHg9YD1dFJaUA,10752
21
+ faster_eth_abi/from_type_str.py,sha256=qHJtLNNHF2BHtRtdemC6hU4eP5jAuorY8qunC7illJI,4631
22
+ faster_eth_abi/grammar.py,sha256=Pd4YmZnQ79tOCrhNDr9eqB5wF2hkBnCJ79kiGGpyv-E,4623
23
+ faster_eth_abi/io.py,sha256=2mnBAYXtiCg1eN-mPkw03z_0rJ_EoB9Bl_XssydAZXM,3984
24
+ faster_eth_abi/packed.cp38-win_amd64.pyd,sha256=OD81y9KLgJxi9F5FejBr4Xjoq-csIezLKLbx2CAkqZE,10752
25
+ faster_eth_abi/packed.py,sha256=STlAhJQSm04B3keAOFGRh8jzk-aCCYAm61_9O9JUn68,437
26
+ faster_eth_abi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ faster_eth_abi/registry.py,sha256=PN2lJ4B0DcOZpUsr148mihbXITTTOamOPG1sn2KgjIk,24529
28
+ faster_eth_abi/typing.py,sha256=8npqU_Nvs-xRTnczC43eJSdaEbrsfERhNJhY9SwNEIg,109647
29
+ faster_eth_abi/tools/__init__.cp38-win_amd64.pyd,sha256=232EVv9SP1PSc4h3vKCp5zfXvqqXHk-YzR161GFiOjM,10752
30
+ faster_eth_abi/tools/__init__.py,sha256=jxyQnb34ldRjCTYi3Ajb5h5QlFQ6ODfKQNhOCVwR7Ao,54
31
+ faster_eth_abi/tools/_strategies.cp38-win_amd64.pyd,sha256=1x2LcthuhMHDt8zL0BBHMZdfWFjY9iNbkEi9aOWrQGE,10752
32
+ faster_eth_abi/tools/_strategies.py,sha256=02wmJpj336nOFu7pBVaH4ucj3FORweKkiGqlaRgy-8c,6330
33
+ faster_eth_abi/utils/__init__.cp38-win_amd64.pyd,sha256=QZ2pvb10QiGvQrMOWst0LKvTbM3x8X-FupweFzGUFSM,10752
34
+ faster_eth_abi/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
+ faster_eth_abi/utils/numeric.cp38-win_amd64.pyd,sha256=iOL1urfFDBlVCnRAH8FS0W-ih7JEsgFwvtDggcDtt4w,10752
36
+ faster_eth_abi/utils/numeric.py,sha256=saAVL12dfDrMXZeao3u2jar-U2y57YKVUqF6VOzoLxs,3395
37
+ faster_eth_abi/utils/padding.cp38-win_amd64.pyd,sha256=EZPMKASmZTG_T7-UF9zTcUWBUXaaELtyG1snD9hr3Ps,10752
38
+ faster_eth_abi/utils/padding.py,sha256=k6dkOiQ3k0OhQUZ6blCiL1VOQVYGyynucafbySjcFfY,515
39
+ faster_eth_abi/utils/string.cp38-win_amd64.pyd,sha256=aThie4SvCbv-jhjkfPRHl-MDlW3SBdrqDDZ-cWZzcmM,10752
40
+ faster_eth_abi/utils/string.py,sha256=wYcvWof4kuitrGGSe_NOduQaxE4HHYmpraCPXKcZxMs,455
41
+ faster_eth_abi/utils/validation.cp38-win_amd64.pyd,sha256=NAj2-IRsMXO1zyY1MtvB-OIYQ8x7Z4kLuQ92WUQiTXo,10752
42
+ faster_eth_abi/utils/validation.py,sha256=9veO7wyQsmcFgeaGrsKdSifjV1gaXfTDDKAt1EbKHYY,539
43
+ faster_eth_abi-5.2.16.dist-info/LICENSE,sha256=Q1lDDWXR057JL2Y7HTAwclCF32_LCloN4sGUkXO1YeI,1127
44
+ faster_eth_abi-5.2.16.dist-info/METADATA,sha256=oJ6wkKW3ybCUzfFGpXNMuThRwtsG9IozjAPNzzaaLz8,7013
45
+ faster_eth_abi-5.2.16.dist-info/WHEEL,sha256=2M046GvC9RLU1f1TWyM-2sB7cRKLhAC7ucAFK8l8f24,99
46
+ faster_eth_abi-5.2.16.dist-info/top_level.txt,sha256=VAQVriOsRsqhSQlZZtJw0zN50hc93HkAqPqL70TVuRU,43
47
+ faster_eth_abi-5.2.16.dist-info/RECORD,,
@@ -1,3 +1,2 @@
1
1
  29859a9e7da9d19bb98c__mypyc
2
- benchmarks
3
2
  faster_eth_abi
benchmarks/__init__.py DELETED
@@ -1 +0,0 @@
1
-
benchmarks/batch.py DELETED
@@ -1,9 +0,0 @@
1
- from typing import (
2
- Any,
3
- Callable,
4
- )
5
-
6
-
7
- def batch(iterations: int, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None:
8
- for _ in range(iterations):
9
- func(*args, **kwargs)
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)