Complexity of standard Python data structures (Re: Speed of string += string)
Tim Peters
tim.one at comcast.net
Mon Apr 14 14:04:57 EDT 2003
[Marcus Alanen]
> ...
> As an example of "unfinished" interfaces: there is no list.clear()
> function, even though dict.clear()
If you want to clear a list,
del list[:]
is the usual way to spell it;
list[:] = []
is also sometimes used. So there isn't a need for a list.clear() method.
dict.clear() can't be spelled efficiently in any other way.
> ...
> If somebody would say "python's list is a really a vector/array",
> that's more or less the only documentation one will ever need,
> help(list) tells the rest. The key characteristics are obvious from
> that one single sentence, right?
I believe they would be to you, but I also believe you're in a minority
there.
Note that it's not true that Python's list is really a vector/array -- the
language doesn't define its implementation, and doesn't want to. It is true
that Python's lists have been implemented as contiguous vectors in the C
implementations of Python so far. I don't know how Jython implements Python
lists, or how Vyper did (a Python derivative implemented in the functional
Ocaml language).
More information about the Python-list
mailing list