2 ms·
For educational purposes (i.e. hooking easily into graphics packages for visualization) you can make a linked list in Python, using elements like: class Node:
by photochemsyn 4y ago
For educational purposes (i.e. hooking easily into graphics packages for visualization) you can make a linked list in Python, using elements like:
class Node:
def __init__(self, dataval=None):
self.dataval = dataval
self.nodepointer = None
The only reason to do this is for education/visualization of data structures, although I'm wondering if this can be engineered to cause a Python memory leak, via circularization of the linked list, or if Python's GC would catch it. Also educational perhaps.
Where linked lists really seem to come into play is with custom manual memory allocators in embedded programming, something of a niche subject.
- NavinF 4y ago> I'm wondering if this can be engineered to cause a Python memory leak, via circularization of the linked list Not unless you manually disable gc. https://docs.python.org/3/library/gc.html https://docs.python.org/3/library/gc.html "Since the collector supplements the reference counting already used in Python, you can disable the collector if you are sure your program does not create reference cycles"