I'm trying to port an existing extension for cPython to PyPy. It is written using C API. I've got some question which are connected with the compatibility:
- The extension uses opcodes from cPython's opcode.h header file. (https://github.com/python/cpython/blob/8a84aef0123bd8c13cf81fbc3b5f6d45f96c2656/Include/opcode.h) There is no such file in the implementation of C API in PyPy. What could you recommend as the best alternative?
- The extension uses some fields of PyThreadState structure. For example, its frame field (https://github.com/python/cpython/blob/8a84aef0123bd8c13cf81fbc3b5f6d45f96c2656/Include/cpython/pystate.h#L59). Is it right to use PyObject_GetAttrString() to access that field in PyPy C API?
- There is no function PyFrame_FastToLocals (https://github.com/python/cpython/blob/8a84aef0123bd8c13cf81fbc3b5f6d45f96c2656/Objects/frameobject.c#L931) in the C API of PyPy. Are there any alternatives?
- Functions PyEval_SetTrace(), PyEval_SetProfile(), PyFrame_GetLineNumber() are defined only in stubs.py in PyPy. (https://foss.heptapod.net/pypy/pypy/-/blob/branch/py3.7/pypy/module/cpyext/stubs.py#L918) Is there a way to get that information in PyPy except patching of its source code?
- Are there any analogues of all PyTrace_* constants (https://github.com/python/cpython/blob/8a84aef0123bd8c13cf81fbc3b5f6d45f96c2656/Include/cpython/pystate.h#L26) in the PyPy C API?
- There is no function PyFrame_Check() (https://github.com/python/cpython/blob/8a84aef0123bd8c13cf81fbc3b5f6d45f96c2656/Include/frameobject.h#L53) in the PyPy C API. Are there any alternatives?