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: optimize HexBytes32 #31

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Changes from all 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
8 changes: 6 additions & 2 deletions evmspec/data/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __new__(cls, address: str):
See Also:
- `cchecksum.to_checksum_address`: Function used for checksum conversion.
"""
return super().__new__(cls, to_checksum_address(address))
return __str_new__(cls, to_checksum_address(address))

@classmethod
def _decode_hook(cls, typ: Type["Address"], obj: str):
Expand Down Expand Up @@ -342,7 +342,7 @@ def __new__(cls, v):
except KeyError as e:
raise ValueError(f"{v} is too long") from e.__cause__

return HexBytes.__new__(cls, missing_bytes + input_bytes)
return __hb_new__(cls, missing_bytes + input_bytes)

def __repr__(self) -> str:
return f"{type(self).__name__}({self.hex()})"
Expand Down Expand Up @@ -456,3 +456,7 @@ async def get_logs(self) -> Tuple["Log", ...]:


class BlockHash(HexBytes32): ...


__str_new__ = str.__new__
__hb_new__ = HexBytes.__new__
Loading