[Python-Dev] PEP 3003 - Python Language Moratorium

Stefan Behnel stefan_ml at behnel.de
Thu Nov 5 11:11:41 CET 2009


Michael Foord, 05.11.2009 10:13:
> Stefan Behnel wrote:
>> if it's intended to name the major
>> implementations, I wonder why Cython is missing from that list.
> 
> Is Cython an implementation of Python?

We certainly aim for Python compatibility. That's a proclaimed 1.0 goal.
Not sure if that means Py3 or Py2 syntax, but that's just a parser detail,
after all.


> It's a grey area, but it seems like Cython is a "Python inspired"
> language (similar to Shedskin) rather than an implementation of Python:
> 
>    The Cython language is very close to the Python language, but Cython
> additionally supports calling C functions and declaring C types on
> variables and class attributes. This allows the compiler to generate
> very efficient C code from Cython code.
>
> (From http://www.cython.org/ )

Cython is different from Shedskin because Shedskin /requires/ the 'Python'
code to be static. Cython does not. It /optimises/ static code, but it will
not complain about dynamic code.

It /does/ make some static assumptions in that it considers builtins true
builtins. However, it does not prevent you from replacing them in your
code, as long as you do it inside the module. Certainly a restriction
compared to Python, where you can import a module into a changed dict
environment that redefines 'object', but not a major restriction IMO, and
certainly not one that impacts much code.


> There are several partial implementations, including Python inspired
> languages, but if we are looking at 'major complete implementations'
> then the current list seems to be: CPython, Jython, IronPython and PyPy.

Cython certainly is not a complete implementation, sure. It still lacks
support for local classes, for example, metaclasses aren't handled, and
generators are still in design stage. But if one of the goals of the
moratorium is to let implementations catch up with the syntax, then Cython
is certainly in line with that. I doubt that there will be much left on the
TODO list two years from now.


> Even Unladen Swallow is a fork (sorry - I mean branch) of CPython rather
> than a separate implementation.

Cython is somewhere in the middle. It's not a fork or branch. Rather, it
depends on the normal CPython runtime for certain features, such as the
standard library, the type/object implementation, garbage collection, and a
couple of dynamic features. But that doesn't prevent it from compiling your
module into an executable application.

Stefan



More information about the Python-Dev mailing list