Skip to content

Commit

Permalink
Merge branch 'master' of github.com:vyperlang/titanoboa into perf
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Feb 16, 2024
2 parents 3f6459a + 8b929f9 commit ba0413c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions boa/interpret.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,20 @@ class BoaImporter(importlib.abc.MetaPathFinder):
def __init__(self):
self._path_lookup = {}

# TODO: replace this with more modern `find_spec()`
def find_module(self, fullname, package_path, target=None):
# note: maybe instead of looping, append path to package_path
path = Path(fullname.replace(".", "/")).with_suffix(".vy")

for prefix in package_path:
# for fullname == "x.y.z"
# prefix looks something like "<...>/site-packages/x"
to_try = Path(prefix).parent / path
for prefix in sys.path:
to_try = Path(prefix) / path

if to_try.exists():
self._path_lookup[fullname] = to_try
return self

return None

# TODO: replace with more modern `exec_module()` and `create_module()`
def load_module(self, fullname):
if fullname in sys.modules:
return sys.modules[fullname]
Expand Down
8 changes: 4 additions & 4 deletions boa/util/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
_parsers: dict[str, ABITypeNode] = {}


# XXX: inherit from bytes directly so that we can pass it to py-evm?
# inherit from `str` so that ABI encoder / decoder can work without failing
class Address(str): # (PYEVM_Address):
# inherit from `str` so that users can compare with regular hex string
# addresses
class Address(str):
# converting between checksum and canonical addresses is a hotspot;
# this class contains both and caches recently seen conversions
__slots__ = ("canonical_address",)
Expand All @@ -42,7 +42,7 @@ def __new__(cls, address):

def __repr__(self):
checksum_addr = super().__repr__()
return f"_Address({checksum_addr})"
return f"Address({checksum_addr})"


class _ABIEncoder(Encoder):
Expand Down

0 comments on commit ba0413c

Please sign in to comment.