[Python-Dev] Using Cython for standard library?

Stefan Behnel stefan_ml at behnel.de
Wed Nov 5 14:10:46 CET 2008

Terry Reedy wrote:
> Stefan Behnel wrote:
>> I think the main advantage for stdlib modules is actually the maintenance
>> cost. Having a single, easy-to-read code base for extension modules that
>> compiles without modification in Py2.6/7 and Py3.0/3.1 (and 2.3, 2.4 and
>> 2.5), makes life a lot easier for both maintainers and backporters.
> Do you have any plans to support/use 3.0 type annotations so that one 
> could develop function-oriented code in 3.0 and then compile efficient C 
> (for whatever CPython version) without adding Python-incompatible cdefs?

That is still an official TODO, but there isn't currently any support for it,
nor any effort to implement it (patches obviously welcome).

The problem is that it only applies to function parameters, not to local
variables or anything else, so the gain is actually very small. On the other
hand, the "pure Python mode", as it is currently implemented, is much more
powerful and allows you to annotate most things in Cython without loosing
the ability to run the code unchanged in plain Python (including Jython and
friends, although I never tested that).


One really neat feature is that you can put a .pxd file next to your .py file
and let it override the function signatures and classes. So you do not even
need Py3 annotations, which have the obvious disadvantage of requiring Py3.


More information about the Python-Dev mailing list