3 ms·
Also, you don't really understand a high-level language unless you understand C. (I'm mostly talking about Python and Java here.) If you think of Python lists a
by ptn 19y ago
Also, you don't really understand a high-level language unless you understand C. (I'm mostly talking about Python and Java here.)
If you think of Python lists as dynamic arrays of pointers to void, the world suddenly becomes easier.
- cstejerean 19y agoIt does? I think that actually makes it less clear what lists in Python are actually good or bad for. I think thinking of them in terms of a linked list in C is a much better abstraction.
- ptn 19y agoA linked list in which every node is a void pointer. But that would be kind of the same. What I meant is that knowing how you would have to implement each of your high-level data structures in C helps you understand some of the problems you encounter when working with them. For example, now I know the difference between these two Python lists: l = [[1,2] for i in range(6)] and l = [1,2] * 6
- ced 19y agoI think of a list just as "a list". An ordered collection of anything. "Linked list" is not an abstraction (at least, not in Python), it's an implementation detail. And IIRC, Python lists are not actually implemented as linked cells, so they have different performance characteristics.