[pypy-dev] offtopic, ontopic, ...

Romain Guillebert romain.py at gmail.com
Tue Feb 14 18:41:30 CET 2012


Hi everyone

Having work on the Python backend for Cython I can give you what I think
are the main hassles.

First, ctypes semantics don't match Cython semantics (which is way
closer, in a good way, to C)

Second, if you work with the AST, you should reimplement stuff that
don't change between Cython and Python + ctypes (ie. the syntax of a
lambda function, ...), this is not really hard to do but takes a lot of
time and is not very rewarding.

However I think it's the right approach considering PyPy's design.

I hope it helped.

Thanks
Romain

On Tue, Feb 14, 2012 at 04:12:16PM +0100, Armin Rigo wrote:
> Hi Stefan,
> 
> On Tue, Feb 14, 2012 at 14:12, Stefan Behnel <stefan_ml at behnel.de> wrote:
> > Hmm, if that is so, how would you ever want to make PyPy bidirectionally
> > interface with anything at all? How does ctypes even work in PyPy?
> 
> I believe you are not understanding my point.  Obviously ctypes works
> in PyPy, and not, I believe, in a particularly "lucky" way at all.  It
> works by not being written as C code at all, but as (Python and)
> RPython code.  The difference of levels between C and RPython is
> essential in PyPy.  I just gave tons of examples of why it is so.  I
> know it's not a perfect solution for everybody; but we think that
> writing C code (or generating it straight from something else) is not
> the most flexible way to develop software.  You may not agree with
> that, and you're free too; but consider that we would be unlikely to
> have a JIT in PyPy at all without the approach we took, so we think
> there is some merit in it.
> 
> Note that I'm pushing so much for a Cython that would emit Python code
> instead of C --- but that's mostly for performance reasons on top of
> PyPy.  The alternative, which is quicker and only slightly more
> hackish, is to complete the C API of cpyext in PyPy until it works
> well enough.  Don't come complaining "it's slow", though.  It *is*
> going to be slow.
> 
> 
> A bientôt,
> 
> Armin.
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> http://mail.python.org/mailman/listinfo/pypy-dev


More information about the pypy-dev mailing list