diff --git a/python/ccxt/static_dependencies/ethereum/utils/hexadecimal.py b/python/ccxt/static_dependencies/ethereum/utils/hexadecimal.py index a4423619e4a06..c196a4609839a 100644 --- a/python/ccxt/static_dependencies/ethereum/utils/hexadecimal.py +++ b/python/ccxt/static_dependencies/ethereum/utils/hexadecimal.py @@ -20,9 +20,13 @@ def decode_hex(value: str) -> bytes: - if not is_text(value): + if not isinstance(value, str): raise TypeError("Value must be an instance of str") - non_prefixed = remove_0x_prefix(HexStr(value)) + # Avoid function call overhead by inlining remove_0x_prefix logic + if value.startswith(("0x", "0X")): + non_prefixed = value[2:] + else: + non_prefixed = value # unhexlify will only accept bytes type someday ascii_hex = non_prefixed.encode("ascii") return binascii.unhexlify(ascii_hex)