Types, Cython, program readability

Stefan Behnel stefan_ml at behnel.de
Sun Mar 16 10:57:16 EDT 2008


Hi,

bearophileHUGS at lycos.com wrote:
> It seems Cython is going to become an efficient and
> general purpose language after all, with optional static typing (its
> purpose: mostly for speed), and it may even gain some kind of macros
> soon. So it may even end replacing Python itself in some situations
> where running efficiency is important, and where Psyco can't be used
> or isn't enough.

Even without any static type annotations, Cython currently runs the supported
portion of pybench some 30% faster than CPython 2.5.1, with for-loops and
if-then-else being multiple times faster. Even on plain Python numbers,
arithmetic gives you a factor of 2 in Cython.

http://comments.gmane.org/gmane.comp.python.cython.devel/680?set_lines=100000

If you need more, C arithmetic and integer loops can easily be enabled with
type annotations, and the Cython project is working on further optimisations
for normal Python code. So if speed is important and the existing code is
supported by Cython (or can be made working), compilation is definitely an option.

Stefan



More information about the Python-list mailing list