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

refactor[lang]: remove VyperNode __hash__() and __eq__() implementations #4433

Merged
merged 9 commits into from
Jan 12, 2025
Prev Previous commit
Next Next commit
refactor ImportsAnalyzer not not use id()
since we no longer need to worry about __hash__ and __eq__performance
charles-cooper committed Jan 1, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d8b2f58cd659c8d7aa84eae228d831c52986e306
9 changes: 4 additions & 5 deletions vyper/semantics/analysis/imports.py
Original file line number Diff line number Diff line change
@@ -58,8 +58,7 @@ def push_path(self, module_ast: vy_ast.Module) -> None:

def pop_path(self, expected: vy_ast.Module) -> None:
popped = self._path.pop()
if expected is not popped: # FIXME - use expected != popped
raise CompilerPanic("unreachable")
assert expected is popped, "unreachable"
self._imports.pop()

@contextlib.contextmanager
@@ -77,7 +76,7 @@ def __init__(self, input_bundle: InputBundle, graph: _ImportGraph):
self.graph = graph
self._ast_of: dict[int, vy_ast.Module] = {}

self.seen: set[int] = set()
self.seen: set[vy_ast.Module] = set()

self.integrity_sum = None

@@ -102,15 +101,15 @@ def _calculate_integrity_sum_r(self, module_ast: vy_ast.Module):
return sha256sum("".join(acc))

def _resolve_imports_r(self, module_ast: vy_ast.Module):
if id(module_ast) in self.seen:
if module_ast in self.seen:
return
with self.graph.enter_path(module_ast):
for node in module_ast.body:
if isinstance(node, vy_ast.Import):
self._handle_Import(node)
elif isinstance(node, vy_ast.ImportFrom):
self._handle_ImportFrom(node)
self.seen.add(id(module_ast))
self.seen.add(module_ast)

def _handle_Import(self, node: vy_ast.Import):
# import x.y[name] as y[alias]