efficient idiomatic queue?

Tim Peters tim.one at home.com
Tue Jan 15 17:55:33 EST 2002


[James_Althoff at i2.com]
> Speaking of generator abuse ...
>
> Anything like this:
>
> def mergesort(alist):
>     if len(alist) <= 1:
>         return iter(alist)
>     return merge(mergesort(alist[:len(alist)//2]),
>         mergesort(alist[len(alist)//2:]))
>
> is probably going to create way too many generator/iterator instances to
> scale well.

Well, it was clear from the start that there's no interest in a practical
algorithm here, else we'd just use a temp array and a handful of index
variables.  "Theoretical efficiency" (O() where a multiplier of 10000000 is
as good as 1) is an interesting area of study, full of papers with schemes
so convoluted the authors cheerfully confess to not even trying to implement
them.

"computer-science"-isn't-about-programming-computers-but-python-is-ly
    y'rs  - tim





More information about the Python-list mailing list