Numeric speed
Josiah Carlson
jcarlson at uci.edu
Wed May 5 19:12:43 EDT 2004
You seem to be new at Python, so I'll give you a some information that
you should know before talking about benchmarking Python:
1. Python is slow.
2. Python evaluates the arguments of a function call before calling the
function. That is, when evaluating the following
sum(xx**1)
xx**1 is evaluated before sum is called. Those who program and/or know
mathematics, call this precidence. Since Python does not include an
optimizer, xx**1 is always called, even though it doesn't do anything.
3. Your benchmark looks to really be testing the performance of the
random number generating array function and the sum functions. I
believe that both are implemented in C. Your "benchmark" therefore, is
benchmarking C vs Fortran. I thought such things were out of vogue 10
years ago. Speaking of which, when will people stop comparing Fortran
(whose optimizing compilers have had 30+ years to evolve) against Python
(whose compilers don't optimize in the classic sense).
4. Posting "benchmarks" without posting the entirety of the code used to
produce the results is fundamentally useless. Did you use the unix
'time' command? Did you use the Python 'time' module? Etcetera.
- Josiah
P.S. Python being slower that Fortran or (insert your favorite language
here) wouldn't surprise me. While Python has been getting faster over
the years, the design considerations are for usability first, speed later.
More information about the Python-list
mailing list