Skip to content

Commit

Permalink
feat: optimize VyperNode.__deepcopy__ (vyperlang#3784)
Browse files Browse the repository at this point in the history
`VyperNode.__deepcopy__` is a hotspot in the frontend. this commit
improves time spent in the frontend by 10%
  • Loading branch information
charles-cooper authored Feb 16, 2024
1 parent 29205ba commit 2d2a682
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vyper/ast/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import decimal
import functools
import operator
import pickle
import sys
import warnings
from typing import Any, Optional, Union
Expand Down Expand Up @@ -357,6 +358,9 @@ def __hash__(self):
values = [getattr(self, i, None) for i in VyperNode.__slots__ if not i.startswith("_")]
return hash(tuple(values))

def __deepcopy__(self, memo):
return pickle.loads(pickle.dumps(self))

def __eq__(self, other):
if not isinstance(other, type(self)):
return False
Expand Down Expand Up @@ -786,7 +790,6 @@ class ExprNode(VyperNode):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self._expr_info = None


Expand Down

0 comments on commit 2d2a682

Please sign in to comment.