Skip to content

Commit b756034

Browse files
committed
perf: implement __slots__ in Node class to optimize memory
- Add __slots__ to prevent per-instance dictionary overhead - Optimize space complexity for large-scale list usage
1 parent 2f0b1b7 commit b756034

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎Sprint-2/implement_linked_list/linked_list.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ class Node:
33
Represents a single person in line.
44
Stores a value and links to the people ahead and behind.
55
"""
6+
__slots__ = ['value', 'next', 'previous']
7+
68
def __init__(self, value):
79
self.value = value
810
self.next = None # The person ahead

0 commit comments

Comments
 (0)