Optimising list comparison

Graham Ashton graz at mindless.com
Sat Mar 16 06:12:48 EST 2002


On Fri, 15 Mar 2002 21:41:46 +0000, Skip Montanaro wrote:

> Psyco <http://sourceforge.net/projects/psyco>.  I added these lines at
> the end of your benchmark script:
> 
>     import psyco
>     psyco.bind(attempt1)
>     psyco.bind(attempt2)
>     benchmark(attempt1)
>     benchmark(attempt2)
> 
> and ran it again.

Bloody hell. That's seriously impressive.

I re-ran the script that I posted in response to Tim's post, but changed
the loop at the bottom to:

    import psyco
    for f in (attempt1, attempt2, attempt3, attempt4, attempt6):
        benchmark(f)
        psyco.bind(f)
        benchmark(f)
	print

Now I get:

ratchet% python listmatch.py
100000 iterations of <function attempt1 at 0x8129bd4> took: 3.357856 secs
100000 iterations of <function attempt1 at 0x8129bd4> took: 0.657385 secs

100000 iterations of <function attempt2 at 0x810340c> took: 7.630363 secs
100000 iterations of <function attempt2 at 0x810340c> took: 7.676283 secs

100000 iterations of <function attempt3 at 0x811c254> took: 4.892329 secs
100000 iterations of <function attempt3 at 0x811c254> took: 0.646776 secs

100000 iterations of <function attempt4 at 0x812b254> took: 3.406146 secs
100000 iterations of <function attempt4 at 0x812b254> took: 0.624154 secs

100000 iterations of <function attempt6 at 0x811c28c> took: 4.721051 secs
100000 iterations of <function attempt6 at 0x811c28c> took: 2.805202 secs

Thanks Skip (and to everybody else who posted suggestions). It's been a
very interesting little discussion.

-- 
Graham



More information about the Python-list mailing list