[Python-Dev] VM and Language summit info for those not at Pycon (and those that are!)

Maciej Fijalkowski fijall at gmail.com
Mon Mar 21 19:12:46 CET 2011


[skipping the whole long discussion]

>
> Cython is meant to compile Python code. A "cython version" would just be a
> pure Python module, usable with all other implementations, but with type
> annotations that make it compile to more optimal C code. Type annotations
> can be provided in an external file (.pxd), using decorators and/or using
> Python 3 annotation syntax. There's also a port of Cython to IronPython
> being written. Additionally, other implementations (such as PyPy) could
> start using the available type declarations in order to improve their
> optimisation capabilities as well.
>

No, PyPy won't be any faster by using Cython type annotations. That
would be missing the whole point. JIT is finding types actually used
without an actual need to tell it to do so. If you really want to
assert isinstance(x, SomeType) would be good enough, but that won't
make anything faster. Places where PyPy is slower than Cython-compiled
code for numeric benchmarks is precisely where those type annotations
actually break Python semantics - for example overflow checking.

Also, from what we (and Unladen Swallow team) found out so far is that
people are actually interested in benchmarks that are "real world",
which in python world usually means "using twisted" or "using django"
or another "using very large library which is a bit hard to find a
hotspot in". That usually means execution time is spread across a
million calls, which makes it infeasible (if not incorrect) to apply
type annotations. That's where (I think) speed.python.org will go,
because that's where most people who contributed benchmarks are
interested in.

We would be happy to run those benchmarks against any VM that can
reasonably run them. Feel also free to contribute a way to run (a
subset of) benchmarks to run under cython, but what we won't do is we
won't provide a custom version of those benchmarks to run with Cython
(type annotations).

Cheers,
fijal


More information about the Python-Dev mailing list