[pypy-dev] What can Cython do for PyPy?

Leonardo Santagada santagada at gmail.com
Thu Aug 12 16:31:01 CEST 2010


On Aug 12, 2010, at 3:49 AM, Stefan Behnel wrote:

> Hi,
> 
> there has recently been a move towards a .NET/IronPython port of Cython, 
> mostly driven by the need for a fast NumPy port. During the related 
> discussion, the question came up how much it would take to let Cython also 
> target other runtimes, including PyPy.
> 
> Given that PyPy already has a CPython C-API compatibility layer, I doubt 
> that it would be hard to enable that. With my limited knowledge about the 
> internals of that layer, I guess the question thus becomes: is there 
> anything Cython could do to the C code it generates that would make the 
> Cython generated extension modules run faster/better/safer on PyPy than 
> they would currently? I never tried to make a Cython module actually run on 
> PyPy (simply because I don't use PyPy), but I have my doubts that they'd 
> run perfectly out of the box. While generally portable, I'm pretty sure the 
> C code relies on some specific internals of CPython that PyPy can't easily 
> (or efficiently) provide.


A possible solution I think would be to do an oo backend for cython. That could be made to generate C# or RPython code. The problem remains that pypy still doesn't have separate compilation so you cannot make a external module for the pypy interpreter after it is translated.

So it is hard, maybe harder than anyone on cython would like, but I still think it is a good solution. (Unless I'm mistaken in any of my assumptions, and then it is a terrible solution :)

--
Leonardo Santagada
santagada at gmail.com






More information about the Pypy-dev mailing list