[Shootout-list] better python implementation for the statistics
bench
Antoine
antoine at pitrou.net
Sun Apr 23 22:56:26 UTC 2006
Hi,
The following Python implementation is a bit better for the statistics
bench. It exhibits a 30% speedup if used with Psyco (compared to the
original one *with* Psyco), a more modest 5% if Pysco is not used.
It uses some little tricks :
- the "reduce" function is slower in many cases than a simple loop
(especially with Psyco)
- the "abs" function is replaced by a local variable pointing to it
(local variables are optimized by the Python interpreter)
- some calculations are avoided inside the loop : this could be used for
other languages as well.
I hope that helps ;)
Regards
Antoine.
PS : i'm not subscribed to the list (i'm already receiving too many
mailing-lists ;()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: moments2.py
Type: application/x-python
Size: 1308 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/shootout-list/attachments/20060423/46f6b297/moments2.bin
More information about the Shootout-list
mailing list