Armin Rigo, 25.07.2011 14:31:
On Mon, Jul 25, 2011 at 1:42 PM, Roberto De Ioris wrote:
We would like to start using PyPy, so our need is having a workable
libpypy.so implementation (we do not need it to be compatible with CPython
api, we can rewrite those parts, expecially in uWSGI, without problems).

Indeed, there is nothing like that so far.  We need to think out the
kind of C-level API which makes sense for libpypy.so to expose.

Wouldn't it make sense to use the Cython port for PyPy here? Usually, embedding just means that there is a two-way bridge between Python and C (or a C-compatible language). Cython basically gives you this, and allows you to design your C-level API any way you want.

However, this means that it has to generate a C module that exports the public C names in one way or another. That won't work with the current approach, which only "compiles" down to Python code that uses ctypes (i.e. the other side). But it shouldn't be too hard to come up with a way to pass calls from the outside C-world into some kind of PyPy API that dispatches them to the appropriate Cython backed implementation. Basically, the external C code would only see a thin generated wrapper for each exported function (or even object) which maps the incoming parameters to ctypes objects, and the complete implementation of the user provided wrapper then runs in PyPy using ctypes.

That would allow the PyPy core developers to design an appropriate public convenience C-API for PyPy, and at the same time allow users to design their own specific C-API for their own code, both using the same tool.

Stefan

_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to