Psyco performance
Christophe
chris.cavalaria at free.fr
Tue Jun 20 12:11:56 EDT 2006
danmcleran at yahoo.com wrote:
> I'm not seeing much benefit from psyco (only 5-10% faster). Maybe this
> example is too trivial? Can someone give me some pointers as to what
> kind of code would see a dramatic benefit?
>
> Here's the code:
>
> import time
> import psyco
>
> n = 100000
>
> t1 = time.clock()
> l = list(range(0,n))
> l2 = [x**2 for x in l]
> t2 = time.clock()
> no_psyco = t2 - t1
>
> psyco.log()
> psyco.full()
>
> t1 = time.clock()
> l = list(range(0,n))
> l2 = [x**2 for x in l]
> t2 = time.clock()
>
> with_psyco = t2 - t1
>
> print 'without psyco = ',no_psyco
> print 'with psyco = ',with_psyco
> print 'delta = ',(((no_psyco - with_psyco)/no_psyco) * 100),'%'
>
Place all the code in a function. Even without psyco you might get
somewhat better performances then. And I doubt psyco can optimise code
that isn't in a function anyway.
And lastly, most of the code is probably spend computing x**2 which is
already optimised C code.
More information about the Python-list
mailing list