efficient idiomatic queue?
eppstein at ics.uci.edu
Mon Jan 14 23:31:27 EST 2002
In article <mailman.1011063861.31491.python-list at python.org>,
"Jason Orendorff" <jason at jorendorff.com> wrote:
> The given operations are usually "quick enough", for small lists
> (less than, say, 5000 items) since the constant coefficient is
> small, compared to the ordinary semi-inefficiency of running
> Python code in the first place.
I'm not sure what you mean by quick enough, but when I tried draining a
list by repeated del L, on lists of 10000 elements it took roughly a
second -- more time than I'd like to spend in most interactive situations.
My philosophy to writing general purpose code like a sorting routine is to
use as efficient algorithms as reasonably possible, because even if you
think you are only going to see 5000-element lists and that 1-second delays
are acceptable, someone later may well try it on a million-element list and
get disgusted when the program takes hours to run. I don't mind using
Python compared to faster languages like C, for programs where fast runtime
is not as critical, if the slowdown is limited to constant factor like 10
or 100. But I wouldn't make me happy if the same "it's quick enough"
attitude led to programs with gratuitously inefficient algorithms that
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list