[Cython] porting mpi4py to PyPy runtime
After successfully porting mpi4py to PyPy 1.9, I want to share a few
issues I've encountered. The most serious onesare on PyPy's side, but
Cython do require a cuple of very minor fixes.
1) Cython uses _PyLong_AsByteArray() to convert integers of unknown
sizeof larger than long long. I had to cinclude the following code to
get the C sources compile:
static int
_PyLong_AsByteArray(PyLongObject* v, unsigned char* bytes, size_t n,
int little_endian, int is_signed)
{
PyErr_SetString(PyExc_RuntimeError,
"PyPy: _PyLong_AsByteArray() not available");
return -1;
}
2) PyPy's implementation of PyBuffer_FillInfo() has a bug, it ignores
the "readonly" parameter instead of generating an error if readonly=1
and PyBUF_WRITABLE is on. I had to to cinclude the following code to
monkeypatch it:
static int
PyBuffer_FillInfo_PyPy(Py_buffer *view, PyObject *obj, void *buf,
Py_ssize_t len, int readonly, int flags)
{
if (view == NULL) return 0;
if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
(readonly == 1)) {
PyErr_SetString(PyExc_BufferError,
(Continue reading)