No built-in swap function?

Terry Reedy tjreedy at udel.edu
Wed Apr 21 13:21:49 EDT 2004


"Simon Wittber" <drconrad at metaplay.com.au> wrote in message
news:000201c42764$5f43d3b0$0000fea9 at simonxp...
> And received the following output:
> 1 million tuple swaps in 1.78324228359 seconds.
> 1 million temp swaps in 1.53032270861 seconds.
> 1 million xor swaps in 2.17933312753 seconds.
>
> Interestingly, using psyco.full() produced these results:
> 1 million tuple swaps in 3.06005958858 seconds.
> 1 million temp swaps in 3.01621882111 seconds.
> 1 million xor swaps in 3.03376686143 seconds.

I *suspect* that what this means is that Psyco adds about 50% to function
call overhead due checking types to determine which specilized
machine-coded version to call.  With any substantial optimizable
computation done within the function, this is still a net win, but not when
the function body is trivial.

Terry J. Reedy







More information about the Python-list mailing list