[Python-Dev] Linked lists

Guido van Rossum guido at python.org
Wed Dec 14 21:37:31 CET 2005


On 12/14/05, Martin Blais <blais at furius.ca> wrote:
> Hello again.
>
> As I'm digging deeper into LISP and Scheme these days, I was
> wondering, is there a good compelling reason why in Python we don't
> have a native singly-linked and doubly-linked list types?
>
> That is, reasons other than
> - "you can get by without it" (sometimes I *want* lists), or
> - "you can use tuples to emulate lists" (only in limited contexts, and
> it's not pretty), or
> - "you can code your own in Python" (not as efficient as native types)
>
> Maybe I'm slapping an old horse here, but searching the archives I
> could not find some relevant controversy, that would--I hoped--include
> a final word from the BDFL.
>
> If I had "real" lists I would use them more often, where I now use
> Python lists (vectors, really).  (Although In LISP I have the reverse
> problem, I tend to use lists sometimes where I should use arrays--I
> think I need to grow up).
>
> Anyway, why not provide good lists or cons-cell classes in C?

So here's a word from the BDFL. :)

I'm curious about the use cases you have in mind.

Python's philosophy about (built-in) data types, inherited from ABC,
is to offer a few powerful clearly distinct choices rather than lots
of alternatives with overlapping usages. This reduces the time it
takes to choose a data type and reduces the risk of picking the wrong
type. (You seem to be indicating that this is indeed what's happening
to you in Lisp. :-)

In this philosophy, there is a real cost associated with offering more
data types which isn't necessarily offset by the advantage.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list