A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-October/146665.html below:

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

[Python-Dev] Optimizing list.sort() by checking type in advance [Python-Dev] Optimizing list.sort() by checking type in advancePaul Moore p.f.moore at gmail.com
Tue Oct 11 11:12:12 EDT 2016
On 11 October 2016 at 15:32, Elliot Gorokhovsky
<elliot.gorokhovsky at gmail.com> wrote:
> 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.

Did I not say earlier - sorry. I'm suggesting that you put each timing
run into a separate Python process.

# Optimised code
python -m perf timeit -s "from mymod import FastList; L=<whatever you
do to create the list>;F=FastList(L)" "F.fastsort()"
# Core sort routine
python -m perf timeit -s "L=<whatever you do to create the list>" "L.sort()"
# Or maybe, if FastList exposes the existing sort function as well
# Non-optimised code
python -m perf timeit -s "from mymod import FastList; L=<whatever you
do to create the list>;F=FastList(L)" "F.sort()"

Paul.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4