Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement cchecksum for ~2x faster checksumming #17

Merged
merged 9 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions eth_pydantic_types/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ def __eth_pydantic_validate__(cls, value: Any, info: Optional[ValidationInfo] =
return cls.to_checksum_address(value)

@classmethod
def to_checksum_address(cls, value: str) -> "ChecksumAddress":
# perf: eth_utils imports are too slow. Hence they are localized.
from eth_utils import is_checksum_address, to_checksum_address

if is_checksum_address(value):
return value # type: ignore[return-value]

else:
return to_checksum_address(value)
def to_checksum_address(cls, value: str) -> ChecksumAddress:
# perf: localized import for module loading performance reasons.
from cchecksum import to_checksum_address

return to_checksum_address(value)


class _AddressTypeFactory:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
url="https://github.com/ApeWorX/eth-pydantic-types",
include_package_data=True,
install_requires=[
"cchecksum>=0.0.3,<1",
"hexbytes>=0.3.1,<2",
"eth-utils>=2.3.1,<6",
"eth-typing>=3.5.2,<6",
Expand Down
Loading