From ebbbef107c41037d957f1fe3219526c002da20e8 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:10:44 -0400 Subject: [PATCH] feat: optimize `uint.__new__` (#34) * feat: optimize `uint.__new__` * chore: `black .` * Update uints.py --------- Co-authored-by: github-actions[bot] --- evmspec/data/uints.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/evmspec/data/uints.py b/evmspec/data/uints.py index 1df5411..70f3e51 100644 --- a/evmspec/data/uints.py +++ b/evmspec/data/uints.py @@ -54,7 +54,7 @@ def __new__(cls, v: HexBytes): >>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935) """ - new = super().__new__(cls, v.hex() if v else "0x0", 16) + new = __int_new__(cls, v.hex() if v else "0x0", 16) if new < cls.min_value: raise ValueError( f"{v!r} ({new}) is smaller than {cls.__name__} min value {cls.min_value}" @@ -140,3 +140,5 @@ class uint256(_UintData): setattr(sys.modules[__name__], cls_name, new_cls) __all__ = [f"uint{bytes*8}" for bytes in range(1, 32)] + +__int_new__ = int.__new__