The REALLY bad thing about Python lists ..
Remco Gerlich
scarblac-spamtrap at pino.selwerd.nl
Sun May 14 17:13:55 EDT 2000
Mike Coffin wrote in comp.lang.python:
> Michael Hudson <mwh21 at cam.ac.uk> writes:
>
> > So create it by appending n elements and then reverse it... this is
> > still n^2, I guess, but for the numbers you can deal with before the
> > universe dies a heat death, this will be vastly quicker than anything
> > else you can do in Python.
>
> Reversing a list is not N^2, it's linear in N.
Appending is O(n^2) in theory, though, since the list has to be resized (and
copied) every once in a while. In practice this effect is minimal, of
course...
--
Remco Gerlich, scarblac at pino.selwerd.nl
"This gubblick contains many nonsklarkish English flutzpahs, but the
overall pluggandisp can be glorked from context" (David Moser)
More information about the Python-list
mailing list