Refs #32948 -- Added Node.__copy__().
This allows the copy.copy() usage in the Q._combine() method to finish sooner, instead of having to fallback to using the __reduce_ex__(4) method. Thia also avoids having to fall into copy.copy() at in Q._combine(), when combining a Q() with another Q(). Co-authored-by: Keryn Knight <keryn@kerynknight.com>
This commit is contained in:
parent
ed9eca8457
commit
19b866c254
|
@ -183,9 +183,6 @@ class WhereNode(tree.Node):
|
||||||
clone.relabel_aliases(change_map)
|
clone.relabel_aliases(change_map)
|
||||||
return clone
|
return clone
|
||||||
|
|
||||||
def copy(self):
|
|
||||||
return self.clone()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _contains_aggregate(cls, obj):
|
def _contains_aggregate(cls, obj):
|
||||||
if isinstance(obj, tree.Node):
|
if isinstance(obj, tree.Node):
|
||||||
|
|
|
@ -44,6 +44,13 @@ class Node:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s: %s>" % (self.__class__.__name__, self)
|
return "<%s: %s>" % (self.__class__.__name__, self)
|
||||||
|
|
||||||
|
def __copy__(self):
|
||||||
|
obj = self.create(connector=self.connector, negated=self.negated)
|
||||||
|
obj.children = self.children # Don't [:] as .__init__() via .create() does.
|
||||||
|
return obj
|
||||||
|
|
||||||
|
copy = __copy__
|
||||||
|
|
||||||
def __deepcopy__(self, memodict):
|
def __deepcopy__(self, memodict):
|
||||||
obj = self.create(connector=self.connector, negated=self.negated)
|
obj = self.create(connector=self.connector, negated=self.negated)
|
||||||
obj.children = copy.deepcopy(self.children, memodict)
|
obj.children = copy.deepcopy(self.children, memodict)
|
||||||
|
|
Loading…
Reference in New Issue