Post #1450647
2026-04-20 16:54 UTC
Writing a linked list in Python just feels wrong. I know it’s probably homework.
If you must, stdlib has dequeue which is going to be faster and simpler than rolling your own. Plus no reference semantics to deal with.
Replies (2)
-
@MoffKalast@lemmy.world 2026-04-20 18:12
It's a meme job interview question iirc.
-
@Ephera@lemmy.ml 2026-04-20 19:02
Yeah, linked lists are rarely a good idea. Modern memory optimization, where contiguous regions of memory are loaded into CPU caches, means that array-backed lists have better performance in virtually all situations. In a way, I’d want to argue that you should actually only ever roll your own linked lists, because you should only use linked lists when you’re not working in-memory, i.e. when array-backed lists are not an option to begin with.