structseq.h missing from Python.h

Create issue
Issue #3160 resolved
Seth Troisi created an issue

In 2010 cpython added #include "structseq.h" into Python.h see this commit.

I diffed pypy/module/cpyext/include/Python.h” and “cpython/Include/Python.h” and they most matched.

I don’t fully understanding the relation between PyPy and cpython and I apologize if this is a silly question, but should PyPy also move the include into Python.h?

Comments (7)

  1. mattip

    This is for PyStructSequence_InitType2 in NumPy, right? Fixed in 95ba888acdd6, which will be part of the next PyPy release

  2. Seth Troisi reporter

    @mattip this is for NumPy, but for another issue.

    I was trying to cleanup

    /* In python 2, this is not exported from Python.h */
    #include <structseq.h>

    This passes all the tests except LinuxPyPy3

    numpy/core/src/multiarray/typeinfo.c:16:8: error: unknown type name ‘PyStructSequence_Field’

    I’ve just updated the comment to /* In PyPy3, this is not exported from Python.h */.

    The point of this issue was to check if PyPy’s implementation should match cpython’s.

  3. mattip

    Yes it should. PyPy started out as an alternative interpreter for the python language. Then we created cffi so people who were used to ctypes and the C-API would have a performant way to glue C and Python together. But it turns out the world is not ready to abandon the Python C-API, especially the scientific python stack, so we developed this whole other layer to PyPy to emulate the Python C-API. Since it is not well defined, we simply copy CPython’s headers and functions, and added emulation functions to mock what CPython does.

    All this was a long way to say yes, PyPy’s implementation should match CPython’s.

  4. Seth Troisi reporter

    I tried for ~15 minutes to get tests to run locally and didn’t get them to work. Do you think you’d be able to fix this for me? I’m willing to do the work if you’re busy but it would be a steep learning curve for a single PR.



  5. mattip

    It is already done, no need for another PR. To test the fix,

    • in numpy, checkout your branch
    • run the script in numpy/tools/ on your branch which will download and run numpy tests on pypy
    • Apply the one-line fix in 95ba888acdd6 to the include file in pypy3/include and then rerun pypy3/bin/pypy3

  6. Log in to comment