python list handling and Lisp list handling
dr.mtarver at ukonline.co.uk
Fri Apr 24 17:19:22 CEST 2009
This page says that Python lists are often flexible arrays
but also says that their representation is implementation dependent.
As far as I see this should mean that element access in Python should
run in constant time. Now if so this is a boon, because generally
'A list is a sequence of elements, but it is not a single primitive
object; it is made of cons cells, one cell per element. Finding the
nth element requires looking through n cons cells, so elements farther
from the beginning of the list take longer to access. But it is
possible to add elements to the list, or remove elements.'
But are Python lists also indistinguishable from conventional
Lisplists for list processing. For example, can I modify a Python
list non-destructively? Are they equivalent to Lisp lists. Can CAR
and CDR in Lisp be thought of as
def car (x):
def cdr (x):
The idea of a list in which elements can be accessed in constant time
is novel to me.
More information about the Python-list