[Python-Dev] Optimizing list.sort() by checking type in advance (original) (raw)
Paul Moore p.f.moore at gmail.com
Tue Oct 11 11:12:12 EDT 2016
- Previous message (by thread): [Python-Dev] Optimizing list.sort() by checking type in advance
- Next message (by thread): [Python-Dev] Optimizing list.sort() by checking type in advance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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=;F=FastList(L)" "F.fastsort()"
Core sort routine
python -m perf timeit -s "L=" "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=;F=FastList(L)" "F.sort()"
Paul.
- Previous message (by thread): [Python-Dev] Optimizing list.sort() by checking type in advance
- Next message (by thread): [Python-Dev] Optimizing list.sort() by checking type in advance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]