[pypy-dev] Bringing Cython and PyPy closer together
stefan_ml at behnel.de
Wed Feb 22 23:28:35 CET 2012
Stefan Behnel, 22.02.2012 21:39:
> adding to the list.
>> Some more errors that I see in the logs up to that point, which all hint at
>> missing bits of the C-API implementation:
>> specialfloatvals.c:490: error: ‘Py_HUGE_VAL’ undeclared
> CPython simply defines this as
> #ifndef Py_HUGE_VAL
> #define Py_HUGE_VAL HUGE_VAL
> to allow users to override it on buggy platforms.
>> buffmt.c:2589: warning: implicit declaration of function ‘PyUnicode_Replace’
> Some more missing parts of the C-API:
> - PyUnicode_Tailmatch
> - PyFrozenSet_Type
- the Unicode character type functions: Py_UNICODE_ISTITLE(),
Py_UNICODE_ISALPHA(), Py_UNICODE_ISDIGIT(), Py_UNICODE_ISNUMERIC()
Our exec/eval implementation is broken because these are missing:
PyCode_Check(), PyCode_GetNumFree(), PyEval_EvalCode(),
PyEval_MergeCompilerFlags(), PyCF_SOURCE_IS_UTF8, PyRun_StringFlags()
I doubt that they will be all that trivial to implement, so I can live with
not having them for a while. Code that uses exec/eval will just fail to
compile for now.
I had to disable the following tests from Cython's test suite because they
either crash PyPy or at least corrupt it in a way that infects subsequent
With those taken out, I get an otherwise complete test run:
Here are the test results:
It obviously runs longer than a CPython run (22 vs. 7 minutes), even though
the runtime is normally dominated by the C compiler runs. However, having
learned a bit about the difficulties that PyPy has in emulating the C-API,
I'm actually quite impressed how much of this just works at all. Well done.
And last but not least, over on python-dev, MvL proposed these two simple
functions for accessing the tstate->exc_* fields:
- PyErr_GetExcInfo(PyObject** type, PyObject** value, PyObject** tb)
- PyErr_SetExcInfo(PyObject* type, PyObject* value, PyObject* tb)
Makes sense to me. Getting those in would fix our generator/coroutine
implementation, amongst other things.
More information about the pypy-dev