cchecksum 0.0.13__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.13/cchecksum.egg-info → cchecksum-0.0.14}/PKG-INFO +2 -2
- {cchecksum-0.0.13 → cchecksum-0.0.14}/README.md +1 -1
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum/checksum.py +21 -42
- {cchecksum-0.0.13 → cchecksum-0.0.14/cchecksum.egg-info}/PKG-INFO +2 -2
- {cchecksum-0.0.13 → cchecksum-0.0.14}/setup.py +1 -1
- {cchecksum-0.0.13 → cchecksum-0.0.14}/.github/workflows/black.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/.github/workflows/deploy-docs.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/.github/workflows/pytest.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/.github/workflows/release.yaml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/.gitignore +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/LICENSE +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/Makefile +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum/__init__.py +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum/_checksum.c +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum/_checksum.pyi +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum/_checksum.pyx +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum/checksum.pyi +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum/py.typed +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum.egg-info/SOURCES.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum.egg-info/dependency_links.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum.egg-info/not-zip-safe +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum.egg-info/requires.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/cchecksum.egg-info/top_level.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/Makefile +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/alabaster.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/basic.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/custom.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/doctools.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/documentation_options.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/file.png +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/language_data.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/minus.png +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/plus.png +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/pygments.css +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/searchtools.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/_build/html/_static/sphinx_highlight.js +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/conf.py +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/index.rst +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/docs/make.bat +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/pyproject.toml +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/requirements.txt +0 -0
- {cchecksum-0.0.13 → cchecksum-0.0.14}/setup.cfg +0 -0
- {cchecksum-0.0.13 → 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,10 +1,10 @@
|
|
|
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
5
|
from eth_typing import AnyAddress, ChecksumAddress, HexAddress, HexStr
|
|
6
|
-
from eth_utils import encode_hex, is_hexstr, remove_0x_prefix
|
|
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
|
|
@@ -16,6 +16,7 @@ keccak(b"")
|
|
|
16
16
|
hash_address = compose(hexlify, bytes, keccak.hasher, str.encode)
|
|
17
17
|
|
|
18
18
|
hex_address_fullmatch = _HEX_ADDRESS_REGEXP.fullmatch
|
|
19
|
+
hex_fullmatch = _HEX_REGEXP.fullmatch
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
# this was ripped out of eth_utils and optimized a little bit
|
|
@@ -80,12 +81,23 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
|
|
|
80
81
|
- :func:`eth_utils.to_normalized_address` for the standard implementation.
|
|
81
82
|
- :func:`is_address` for checking if a string is a valid address.
|
|
82
83
|
"""
|
|
83
|
-
|
|
84
|
-
hex_address =
|
|
85
|
-
|
|
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:
|
|
86
98
|
raise TypeError(
|
|
87
|
-
f"
|
|
88
|
-
)
|
|
99
|
+
f"Unsupported type: '{repr(type(value))}'. Must be one of: bytes or bytearray."
|
|
100
|
+
)
|
|
89
101
|
|
|
90
102
|
# if `hex_address` is not a valid address
|
|
91
103
|
if hex_address_fullmatch(hex_address) is None:
|
|
@@ -96,39 +108,6 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
|
|
|
96
108
|
return hex_address # type: ignore [return-value]
|
|
97
109
|
|
|
98
110
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def hexstr_if_str(hexstr_or_primitive: Union[bytes, int, str]) -> HexStr:
|
|
103
|
-
"""
|
|
104
|
-
Convert to a type, assuming that strings can be only hexstr (not unicode text).
|
|
105
|
-
|
|
106
|
-
:param hexstr_or_primitive bytes, str, int: value to convert
|
|
107
|
-
"""
|
|
108
|
-
if isinstance(hexstr_or_primitive, str):
|
|
109
|
-
if remove_0x_prefix(hexstr_or_primitive) and not is_hexstr(hexstr_or_primitive):
|
|
110
|
-
raise ValueError(
|
|
111
|
-
"when sending a str, it must be a hex string. " f"Got: {repr(hexstr_or_primitive)}"
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
hexstr_or_primitive
|
|
116
|
-
if hexstr_or_primitive.startswith(("0x", "0X"))
|
|
117
|
-
else f"0x{hexstr_or_primitive}"
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
elif isinstance(address_bytes, (bytes, bytearray)):
|
|
121
|
-
return encode_hex(address_bytes)
|
|
122
|
-
|
|
123
|
-
elif isinstance(address_bytes, memoryview):
|
|
124
|
-
return encode_memoryview(address_bytes)
|
|
125
|
-
|
|
126
|
-
raise TypeError(
|
|
127
|
-
f"Unsupported type: '{repr(type(address_bytes))}'. Must be one of: bytes or bytearray."
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
del hexlify
|
|
132
|
-
del Optional, Union
|
|
111
|
+
del AnyStr, Optional, Union
|
|
133
112
|
del AnyAddress, ChecksumAddress, HexAddress, HexStr
|
|
134
|
-
del _HEX_ADDRESS_REGEXP, compose, keccak
|
|
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
|