pyskip
pyskip copied to clipboard
Memory improvement and _sizeof__ for skiplist
Important for skip list is the memory usage (compared to linked lists etc.), especially depending on the max layers. Some more infos of it in runtime would be nice
Would suggest something for the skiplist class like:
import sys
...
def __sizeof__(self):
return sum([sys.getsizeof(x) for x in self.layers])
...
Suggestion for usage of: slots
Reductio of overhead for instanciation of heave used classes
e.g.:
class Foo:
__slots__ = ["x", "y"]
def __init__(self, x, y):
self.x = x
self.y = y
It removes the attribute dict of instance and therefore reduces memory usage.