Re: What about an EXPLICIT naming scheme for built-ins?

From: Andrew Durdin (adurdin_at_gmail.com)
Date: 09/04/04


Date: Sat, 4 Sep 2004 08:53:42 +1000
To: python-list@python.org

On Fri, 3 Sep 2004 12:05:38 -0300, Carlos Ribeiro <carribeiro@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.



Relevant Pages

  • Re: technique to enter text using a mobile phone keypad (T9 dictionary-based disambiguation)
    ... removing the stripping) reduces the running time enough: ... conv = string.maketrans ... If the words file is already sorted you can skip the sorting line. ...
    (comp.lang.python)
  • Re: Help understanding the decisions *behind* python?
    ... the first element: ... That requires sorting the entire list, ... I find it interesting that the heapq functions tell you in the ... integers it isn't worth sorting unless you want more than about 700 items. ...
    (comp.lang.python)
  • Re: Sorting a list
    ... don't even need a regexp here. ... But wrt/ sorting, the list of tuples with the sort key as first element is one of the best solutions. ...
    (comp.lang.python)
  • sort cluster efficiency
    ... i sort this cluster by the first element. ... the problem is that my array is about a few tens Mb, which takes about 500ms to compute and prepare before sorting. ...
    (comp.lang.labview)