[Python-Dev] Optimizing list.sort() by checking type in advance

Elliot Gorokhovsky elliot.gorokhovsky at gmail.com
Tue Oct 11 10:32:00 EDT 2016


But the sort mutates F...does the setup get executed each time? I thought
it's just at the beginning. So then F gets mutated (sorted) and subsequent
sorts time wrong.

On Tue, Oct 11, 2016, 7:51 AM Paul Moore <p.f.moore at gmail.com> wrote:

> On 11 October 2016 at 14:04, Elliot Gorokhovsky
> <elliot.gorokhovsky at gmail.com> wrote:
> > Right, that sounds good, but there's just one thing I don't understand
> > that's keeping me from using it. Namely, I would define a benchmark list
> L
> > in my setup, and then I would have code="F=FastList(L);F.fastsort()". The
> > problem here is I'm measuring the constructor time along with the sort
> time,
> > right, so wouldn't that mess up the benchmark? Or does timeit separate
> the
> > times?
>
> That would mess up your times. Put F=FastList(L) in your setup.
>
> Paul
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20161011/615dbb11/attachment.html>


More information about the Python-Dev mailing list