## DEV Community is a community of 605,533 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Discussion on: What are Linked Lists and How Do I Make One in Python?

## Replies for: Shorter technique: my_list = List() ;) But yes, what you showed is the way you'd create your own linked list in Python! Now I'd be curious why you...

Whiteboarding with Erik

If you're not worried about performance, then yes, it's easier to use a Python list. The reason for learning how to implement a linked list is along the lines of learning math when you can use a calculator–it's more about learning the concept. It's hotly debated in the developer community whether technical interviews that ask data structures and algorithms problem are really necessary. I don't know the answer to this. This article series is meant to prepare students who only know Python for these kinds of interview questions.

One advantage is that this simple linked list class provides a base to make our own specialized list class with custom methods, which I'll do in a future article when we use our linked list class to make a simple blockchain. So stay tuned for the DIY Bitcoin article!

Jason C. McDonald • Edited

Ah, okay, I was merely under the impression that `List` had been implemented as a linked list. (I already know the difference between fixed-length array, dynamic-length array, and linked list, but your explanation will be helpful to anyone who isn't.)

Whiteboarding with Erik

I also was unaware how `list` is implemented in Python. So we both learned something :)

Jason C. McDonald • Edited

On nerd-level discussion of data structures (language agnostic now), another good option for a dynamic contiguous collection is a circular buffer, which is designed such that the head and tail "float". It's a bit hard to explain — basically, you don't require head to be at element 0, but implement logic for "wrapping around" from the last element to the first, as long as you haven't yet reached tail.

It makes for a time complexity of O(n/2) on insertion/deletion without reallocation, instead of the O(n) of a typical contiguous collection. Even better, head and tail operations are always Θ(1). While this is still a bit higher than the consistent O(1) of a linked list, you don't have the cache misses. It's also better-suited for random access.

No idea how you'd effectively implement this in Python, however. I always use pointer arithmetic to pull it off.