Super Tuples
Gordon McMillan
gmcm at hypernet.com
Thu Dec 30 23:16:41 EST 1999
Cliff Crawford wrote:
> Pada 30 Dec 1999 15:49:45 +0100, Magnus L. Hetland bilang:
> |
> | I guess these things in Python have a lot to do with the
> underlying | C-implementation, since tuples in many circumstances
> are quite | efficient, and one-element tuples may be used to be
> consistent | sometimes.
>
> I thought that lists and tuples had the same underlying
> implementation (C arrays). The only difference is that lists are
> mutable while tuples aren't.
Tuples take one allocation, lists take a minimum of two.
> Actually, this has always bugged
> me--you'd think that "lists" would be similar to lists in Lisp
> (i.e. constant time insertions and deletions), but they're not.
> It seems to me it would make more sense to implement mutable
> sequences using a linked list rather than an array.
Linked lists only work well when the link(s) are part of the
objects. An intelligently realloced array will beat the pants off
a (obj *, next *) linked list, and for most operations, will beat
embedded links, too.
- Gordon
More information about the Python-list
mailing list