[Tutor] python list, right! but concretely?

Alan Gauld alan.gauld at btinternet.com
Sun May 2 09:49:30 CEST 2010


"spir ☣" <denis.spir at gmail.com> wrote
> Is there anywhere some introduction material to the implementation
> of python lists (or to fully dynamic and flexible sequences, in general)?

The definitive information is the source code which is freely available.

> More precisely, I'd like to know what kind of base data-structure
> is used (linked list, dynamic array, something else -- and in case of
> array, how is resizing computed).

I'd look to the source for that. It may be a combination of traditional
techniques. But I've never been curious enough to look :-)

> Also, how is "generics" (element are of free type, and even
> heterogeneous) managed?

Everything is an object in Python. So it is a list of objects.

> no computer science knowledge. I have a working implementation
> of linked lists in primitive languages ;-) (namely C & Pascal),
> but rather complicated to my taste; and I'm probably overlooking
> commonly known and used tricks that could make the algorithm
> simpler or more efficient.

Hmm, Linked lists in C and Pascal are usually pretty trivial.
Unless you have done something unusual its hard to think how
you could simplify them. You can complexify them for better speed
or storage efficiency but the basic linked list in either language
is about as simple as dynamic data gets.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list