What about an EXPLICIT naming scheme for built-ins?

Andrew Durdin adurdin at gmail.com
Fri Sep 3 18:53:42 EDT 2004


On Fri, 3 Sep 2004 12:05:38 -0300, Carlos Ribeiro <carribeiro at gmail.com> wrote:
> 
> -- overall responsiveness in applications where sort is frequently
> called. Instead of waiting for the full sort at each sorted() call,
> the running time of the sorting method would be divided between the
> calls to the generator. Interactive and multithreaded applications can
> benefit of this approach

So a generator-based implementation could amortize the cost of sorting
over several calls. Whether this will provide a significant benefit
would depend on the algorithm used; quicksort at least wouldn't
provide much benefit, as you'd still use O(log n) time to do the
partitioning needed to get the first element, while returning
subsequent elements would be quicker. I think that for a multithreaded
app (at least), you'd be better off having a thread that does the
sorting, and pushes the results into a shared Queue as it gets them,
and the main thread pulls them out as they come.
 
> p.s. I opted to send a copy of this answer to the list, I think it's
> good for the discussion. I hope you don't mind.

Oops -- I'd meant to send my reply to the list, but forgot to change
the default recipient.



More information about the Python-list mailing list