[Cython] pybench shootout between Cython 0.9.6.12+ and Python 2.5.1

Stefan Behnel stefan_ml at behnel.de
Wed Mar 5 20:18:07 CET 2008


Hi,

I got most of pybench running (as shipped with Python 2.5.1), just had to
rename the .py files to .pyx (except Setup.py) and fix some "*" imports in the
configuration, Cython does not allow that.

Benchmark suites that run:
- Arithmetic
- Constructs
- Lists
- Tuples
- Dict
- Exceptions
- Imports
- Strings
- Numbers
- Unicode

Benchmark suites that do not run:
- Calls
- Lookups
- Instances
- NewInstances

The main problem is that they define classes and functions dynamically, which
is not currently supported by Cython.

The attached text file compares the results of a stock Python 2.5.1 from
Ubuntu Gutsy to a Cython compiled version of the benchmarks. Positive
differences mean that Python is slower than Cython. (I couldn't manage to get
the opposite comparison running due to pickle problems).

The end result is that Cython is almost 1/3 faster than the Python interpreter
for plain Python code. Especially control structures like if/else and loops
gain a lot from compilation, even for plain Python loops.

BIG FAT WARNING: Please do not overrate these numbers, this is an unfair
comparison between an interpreter and a compiler that do not even understand
the same language. Also, I didn't compile Python myself, so the compiler
optimisations differ between the two. However, I did not alter the benchmarks
themselves in any way, so all benchmark functions use exactly the same Python
source code in both runs.

The "0ms" that Cython gives you in a couple of tests are actually real. They
mean that the timings were not measurable compared to the overhead of the
benchmark call itself, which is credible for an empty try-except, for example,
or the comparison of numbers.

Have fun,
Stefan

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cybench-compare.txt
Url: http://codespeak.net/pipermail/cython-dev/attachments/20080305/eec8b962/attachment-0001.txt 


More information about the Cython-dev mailing list