cchecksum 0.0.12__tar.gz → 0.0.14__tar.gz
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 cchecksum might be problematic. Click here for more details.
- {cchecksum-0.0.12/cchecksum.egg-info → cchecksum-0.0.14}/PKG-INFO +2 -2
- {cchecksum-0.0.12 → cchecksum-0.0.14}/README.md +1 -1
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum/checksum.py +23 -43
- {cchecksum-0.0.12 → cchecksum-0.0.14/cchecksum.egg-info}/PKG-INFO +2 -2
- {cchecksum-0.0.12 → cchecksum-0.0.14}/setup.py +1 -1
- {cchecksum-0.0.12 → cchecksum-0.0.14}/.github/workflows/black.yaml +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/.github/workflows/deploy-docs.yaml +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/.github/workflows/pytest.yaml +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/.github/workflows/release.yaml +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/.gitignore +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/LICENSE +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/Makefile +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum/__init__.py +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum/_checksum.c +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum/_checksum.pyi +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum/_checksum.pyx +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum/checksum.pyi +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum/py.typed +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum.egg-info/SOURCES.txt +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum.egg-info/dependency_links.txt +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum.egg-info/not-zip-safe +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum.egg-info/requires.txt +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/cchecksum.egg-info/top_level.txt +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/Makefile +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/alabaster.css +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/basic.css +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/custom.css +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/doctools.js +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/documentation_options.js +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/file.png +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/language_data.js +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/minus.png +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/plus.png +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/pygments.css +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/searchtools.js +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/_build/html/_static/sphinx_highlight.js +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/conf.py +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/index.rst +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/docs/make.bat +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/pyproject.toml +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/requirements.txt +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/setup.cfg +0 -0
- {cchecksum-0.0.12 → cchecksum-0.0.14}/test_checksum.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cchecksum
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: A ~
|
|
3
|
+
Version: 0.0.14
|
|
4
|
+
Summary: A ~5x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.
|
|
5
5
|
Home-page: https://github.com/BobTheBuidler/cchecksum
|
|
6
6
|
Author: BobTheBuidler
|
|
7
7
|
Author-email: bobthebuidlerdefi@gmail.com
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## CChecksum
|
|
2
2
|
|
|
3
|
-
CChecksum is a ~
|
|
3
|
+
CChecksum is a ~5x faster drop-in replacement for eth_utils.to_checksum_address, with the most cpu-intensive part implemented in c.
|
|
4
4
|
|
|
5
5
|
It keeps the exact same API as the existing implementation, exceptions and all.
|
|
6
6
|
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
from binascii import hexlify
|
|
2
|
-
from typing import Optional, Union
|
|
2
|
+
from typing import AnyStr, Optional, Union
|
|
3
3
|
|
|
4
4
|
from eth_hash.auto import keccak
|
|
5
|
-
from eth_typing import AnyAddress, ChecksumAddress, HexAddress, HexStr
|
|
6
|
-
from eth_utils import encode_hex, hexstr_if_str
|
|
5
|
+
from eth_typing import AnyAddress, ChecksumAddress, HexAddress, HexStr
|
|
7
6
|
from eth_utils.address import _HEX_ADDRESS_REGEXP
|
|
7
|
+
from eth_utils.hexadecimal import _HEX_REGEXP
|
|
8
8
|
from eth_utils.toolz import compose
|
|
9
9
|
|
|
10
10
|
from cchecksum._checksum import cchecksum
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
BytesLike = Union[Primitives, bytearray, memoryview]
|
|
14
|
-
|
|
15
|
-
|
|
16
13
|
# force _hasher_first_run and _preimage_first_run to execute so we can cache the new hasher
|
|
17
14
|
keccak(b"")
|
|
18
15
|
|
|
19
16
|
hash_address = compose(hexlify, bytes, keccak.hasher, str.encode)
|
|
20
17
|
|
|
21
18
|
hex_address_fullmatch = _HEX_ADDRESS_REGEXP.fullmatch
|
|
19
|
+
hex_fullmatch = _HEX_REGEXP.fullmatch
|
|
22
20
|
|
|
23
21
|
|
|
24
22
|
# this was ripped out of eth_utils and optimized a little bit
|
|
@@ -83,12 +81,23 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
|
|
|
83
81
|
- :func:`eth_utils.to_normalized_address` for the standard implementation.
|
|
84
82
|
- :func:`is_address` for checking if a string is a valid address.
|
|
85
83
|
"""
|
|
86
|
-
|
|
87
|
-
hex_address =
|
|
88
|
-
|
|
84
|
+
if isinstance(value, str):
|
|
85
|
+
hex_address = (value if value.startswith(("0x", "0X")) else f"0x{value}").lower()
|
|
86
|
+
|
|
87
|
+
# if `value` has content and is not a hexstring
|
|
88
|
+
if hex_address[2:] and hex_fullmatch(hex_address) is None:
|
|
89
|
+
raise ValueError("when sending a str, it must be a hex string. " f"Got: {repr(value)}")
|
|
90
|
+
|
|
91
|
+
elif isinstance(value, (bytes, bytearray)):
|
|
92
|
+
hex_address = f"0x{hexlify(value).decode('ascii')}".lower()
|
|
93
|
+
|
|
94
|
+
elif isinstance(value, memoryview):
|
|
95
|
+
hex_address = f"0x{hexlify(bytes(value)).decode('ascii')}".lower()
|
|
96
|
+
|
|
97
|
+
else:
|
|
89
98
|
raise TypeError(
|
|
90
|
-
f"
|
|
91
|
-
)
|
|
99
|
+
f"Unsupported type: '{repr(type(value))}'. Must be one of: bytes or bytearray."
|
|
100
|
+
)
|
|
92
101
|
|
|
93
102
|
# if `hex_address` is not a valid address
|
|
94
103
|
if hex_address_fullmatch(hex_address) is None:
|
|
@@ -99,35 +108,6 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
|
|
|
99
108
|
return hex_address # type: ignore [return-value]
|
|
100
109
|
|
|
101
110
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def to_hex(
|
|
106
|
-
address_bytes: Optional[BytesLike] = None,
|
|
107
|
-
*,
|
|
108
|
-
hexstr: Optional[HexStr] = None,
|
|
109
|
-
) -> HexStr:
|
|
110
|
-
"""
|
|
111
|
-
Auto converts any supported value into its hex representation.
|
|
112
|
-
Trims leading zeros, as defined in:
|
|
113
|
-
https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding
|
|
114
|
-
"""
|
|
115
|
-
if hexstr is not None:
|
|
116
|
-
return hexstr if hexstr.startswith(("0x", "0X")) else f"0x{hexstr}"
|
|
117
|
-
|
|
118
|
-
if isinstance(address_bytes, (bytes, bytearray)):
|
|
119
|
-
return encode_hex(address_bytes)
|
|
120
|
-
|
|
121
|
-
if isinstance(address_bytes, memoryview):
|
|
122
|
-
return encode_memoryview(address_bytes)
|
|
123
|
-
|
|
124
|
-
raise TypeError(
|
|
125
|
-
f"Unsupported type: '{repr(type(address_bytes))}'. Must be one of: bytes or bytearray."
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
del hexlify
|
|
130
|
-
del Optional, Union
|
|
131
|
-
del AnyAddress, ChecksumAddress, HexAddress, HexStr, Primitives
|
|
132
|
-
del _HEX_ADDRESS_REGEXP, compose, keccak
|
|
133
|
-
del BytesLike
|
|
111
|
+
del AnyStr, Optional, Union
|
|
112
|
+
del AnyAddress, ChecksumAddress, HexAddress, HexStr
|
|
113
|
+
del _HEX_ADDRESS_REGEXP, _HEX_REGEXP, compose, keccak
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cchecksum
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: A ~
|
|
3
|
+
Version: 0.0.14
|
|
4
|
+
Summary: A ~5x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.
|
|
5
5
|
Home-page: https://github.com/BobTheBuidler/cchecksum
|
|
6
6
|
Author: BobTheBuidler
|
|
7
7
|
Author-email: bobthebuidlerdefi@gmail.com
|
|
@@ -13,7 +13,7 @@ setup(
|
|
|
13
13
|
"local_scheme": "no-local-version",
|
|
14
14
|
"version_scheme": "python-simplified-semver",
|
|
15
15
|
},
|
|
16
|
-
description="A ~
|
|
16
|
+
description="A ~5x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.",
|
|
17
17
|
author="BobTheBuidler",
|
|
18
18
|
author_email="bobthebuidlerdefi@gmail.com",
|
|
19
19
|
url="https://github.com/BobTheBuidler/cchecksum",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|