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

Stefan Behnel stefan_ml at behnel.de
Sun Mar 20 13:35:46 CET 2011


Antoine Pitrou, 20.03.2011 12:40:
> On Sun, 20 Mar 2011 07:32:34 -0400 Jesse Noller wrote:
>>
>> The reason why there was no mention is probably because no one
>> intimately familiar with Cython was there, and if they were - it was
>> not brought up. If Cython supports PyPy - and Jython, and IronPython,
>> your proposal makes sense. The reason for "pure" python implementation
>> is so that other implementations can share the exact same standard
>> library we have today.
>
> Well, realistically, they don't. Some functionality just isn't
> satisfied with a slow Python implementation. The io module is a primary
> example of that.

Agreed.


> (but I don't think a Cython version of io would be fast enough, either)

I assume you mean a compiled version of the pure Python implementation? No, 
that likely won't be faster and would certainly be much slower than the 
current C implementation. There's not much Cython can optimise in Python 
code that mostly does Python-level I/O operations.

However, I'd argue that if the C implementation of the "io" module had been 
written in Cython code instead of C, it would have ended up being about as 
fast (or maybe slightly faster due to the reduced calling overhead in 
Cython), but substantially shorter, more readable and accessible for Python 
users and consequently easier to maintain. Likely also easier to write in 
the first place, as most of the code had already been written for the pure 
Python version, which makes it a "copy&optimise" rather than a "read&rewrite".

Maybe that would make a good topic for the GSoC: rewrite some of the C 
modules in CPython in Cython, either in pure Python with Cython type 
annotations, or in Cython code, depending on the type of module and its 
speed requirements. Rewriting C code in Cython usually goes quite quickly, 
so the outcome would likely be several modules for one GSoC participant.

IMHO, taking modules that currently only have a C implementation due to 
performance constraints and rewriting them in Cython is a much more 
worthwhile thing to do than adding an alternative pure Python 
implementation that other Python runtimes wouldn't use anyway. And at least 
IronPython could soon benefit directly from a Cython implementation as well.

Stefan



More information about the Python-Dev mailing list