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

mark florisson markflorisson88 at gmail.com
Tue Feb 14 16:28:18 CET 2012

On 14 February 2012 15:25, Martijn Faassen <faassen at startifact.com> wrote:
> On Tue, Feb 14, 2012 at 4:19 PM, Armin Rigo <arigo at tunes.org> wrote:
>> Hi Martijn,
>> On Tue, Feb 14, 2012 at 14:47, Martijn Faassen <faassen at startifact.com> wrote:
>>> But Cython-based code does talk to C APIs, so there is a problem.
>>> Python code in PyPy needs to be able to interface with C APIs first in
>>> order to generate the right stuff from Cython.
>> That's not necessarily hard.  I believe that Cython code like this:
>>   PyObject *x = PyDict_GetItem(y, key)
>> can correspond "faithfully" to Python code like that --- if we assume
>> that 'y' contains really a dict:
>>   x = y[key]
>> I don't know to what extend the whole C API can be mapped back to
>> Python, but certainly the most common functions can.
> Yes, that's the Python C API, but I was talking about other C APIs.
> Take lxml, which uses the libxml2 APIs.
> There is no way to map that to Python unless you use something like
> ctypes (but ctypes is not considered to be right for this purpose).

Why is ctypes not right? Cython could actually generate a C function
with a known interface, that proxies the actual C function. That code
would be compiled by the C compiler, and any C API changes would
prevent the module from compiling. It would also take care of any
promotions etc on the C level.

> Regards,
> Martijn
> _______________________________________________
> 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