Choosing a programming language as a competitive tool

Alex Martelli aleaxit at yahoo.com
Sun May 6 12:12:45 EDT 2001


"Douglas Alan" <nessus at mit.edu> wrote in message
news:lclmobtdc7.fsf at gaffa.mit.edu...
    [snip]
> C or Fortran or Basic or Pascal or Perl.  And the influence of Lisp on
> Python is clear: automatic memory management, variable binding by
> object sharing, call by object sharing, lists as a central data
> structure, bignums, an interactive interpreter, consistent and

While most of these semantic similarities are valid and important,
I think the "lists as a central data structure" one is misleading.

Python and Lisp both have an important data structure each calls
"list" -- but the two data structures in question are nothing like
each other.  Python's so-called "lists" are really vectors, or arrays,
of references -- the references are stored in a contiguous slab of
memory, so that (for example) splicing entries into a list is O(N)
but accessing the i-th element is O(1).  Lisp's "lists" are _linked_
lists made up of cons cells -- accessing the i-th element is O(i),
splicing (&c) is O(1).

Actually, I think the choice of "list" as the name of the Python
structure is somewhat misleading (and that 'array' or 'vector'
might have been better), as 'list' mostly means (even in other
programming communities) something closer to what _Lisp_
means by it... and, Lisp was there first:-).  No biggie, but I
_have_ seen newbies temporarily confused by thinking that
Python lists were, well, lists, and that there seemed to way to
have a vector/array...:-).


Alex






More information about the Python-list mailing list