Add __slots__ in datastruct.py
It does not make a clear difference for performance. But it should at least reduce memory usage a bit.
This commit is contained in:
parent
d2debb6d6f
commit
b2d4de41f9
|
@ -29,9 +29,14 @@ class UnionFindQueue(Generic[_NameT, _ElemT]):
|
|||
tracking added to it.
|
||||
"""
|
||||
|
||||
__slots__ = ("name", "tree", "sub_queues", "split_nodes")
|
||||
|
||||
class Node(Generic[_NameT2, _ElemT2]):
|
||||
"""Node in a UnionFindQueue."""
|
||||
|
||||
__slots__ = ("owner", "data", "prio", "min_node", "height",
|
||||
"parent", "left", "right")
|
||||
|
||||
def __init__(self,
|
||||
owner: "UnionFindQueue[_NameT2, _ElemT2]",
|
||||
data: _ElemT2,
|
||||
|
@ -688,6 +693,8 @@ class UnionFindQueue(Generic[_NameT, _ElemT]):
|
|||
class PriorityQueue(Generic[_ElemT]):
|
||||
"""Priority queue based on a binary heap."""
|
||||
|
||||
__slots__ = ("heap", )
|
||||
|
||||
class Node(Generic[_ElemT2]):
|
||||
"""Node in the priority queue."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue