-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C API: Remove private C API functions (move them to the internal C API) #106320
Comments
Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
See also issue #106316: remove pytime.h header file ( |
See also issue #106084: C API: Remove private functions from abstract.h. |
See also commit 0b51463:
|
Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
Replace calls to the (removed) slow _PyInterpreterState_Get() with fast inlined _PyInterpreterState_GET() function.
* Remove private _PyTracemalloc C API functions: move them to the internal C API. * Rename Include/tracemalloc.h to Include/cpython/tracemalloc.h
* Remove private _PyTracemalloc C API functions: move them to the internal C API. * Don't export private _PyTracemalloc functions anymore. * Rename Include/tracemalloc.h to Include/cpython/tracemalloc.h
* Remove private _PyTraceMalloc C API functions: move them to the internal C API. * Don't export most of these functions anymore, but still export _PyTraceMalloc_GetTraceback() used by tests. * Rename Include/tracemalloc.h to Include/cpython/tracemalloc.h
Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
* Remove private _PyTraceMalloc C API functions: move them to the internal C API. * Don't export most of these functions anymore, but still export _PyTraceMalloc_GetTraceback() used by tests. * Rename Include/tracemalloc.h to Include/cpython/tracemalloc.h
Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
Add internal pycore_complexobject.h header file. Move _Py_c_xxx() functions and _PyComplex_FormatAdvancedWriter() function to this new header file.
…ng() Replace private _PyUnicode_EqualToASCIIString() with public PyUnicode_CompareWithASCIIString().
The only removed functions which were documented in Doc/c-api/ were removed by PR #106085 and PR #106273: the "vectorcall" aliases (doc removed by commit 80b3d8f). No other removed API were documented in Doc/c-api/. There are a few private documented functions, such as _PyTuple_Resize() and _PyBytes_Resize(): allocation.rst:.. c:function:: PyObject* _PyObject_New(PyTypeObject *type)
allocation.rst:.. c:function:: PyVarObject* _PyObject_NewVar(PyTypeObject *type, Py_ssize_t size)
bytes.rst:.. c:function:: int _PyBytes_Resize(PyObject **bytes, Py_ssize_t newsize)
complex.rst:.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
complex.rst:.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
complex.rst:.. c:function:: Py_complex _Py_c_neg(Py_complex num)
complex.rst:.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
complex.rst:.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
complex.rst:.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
frame.rst:.. c:function:: PyObject* PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
frame.rst:.. c:function:: int PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame);
frame.rst:.. c:function:: int PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame);
init.rst:.. c:function:: _PyFrameEvalFunction _PyInterpreterState_GetEvalFrameFunc(PyInterpreterState *interp)
init.rst:.. c:function:: void _PyInterpreterState_SetEvalFrameFunc(PyInterpreterState *interp, _PyFrameEvalFunction eval_frame)
init_config.rst:.. c:function:: PyStatus _Py_InitializeMain(void)
object.rst:.. c:function:: PyObject** _PyObject_GetDictPtr(PyObject *obj)
tuple.rst:.. c:function:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) Stats on private functions documented with the
|
I propose to revert Python 3.13 C API incompatible changes causing most troubles right now. |
Yeah, just do it already. :-) |
Change the API of the internal _PyDict_Pop_KnownHash() function: return an int. Co-Authored-By: Stefan Behnel <[email protected]>
Change the API of the internal _PyDict_Pop_KnownHash() function to return an int. Co-Authored-By: Stefan Behnel <[email protected]>
Note that the documented functions |
Oh I forgot the details about _Py_c_sum() functions, they are now discussion in gh-112019. I suggest to move the discussion there. |
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
…#111162) * pythongh-106320: Re-add _PyLong_FromByteArray(), _PyLong_AsByteArray() and _PyLong_GCD() to the public header files since they are used by third-party packages and there is no efficient replacement. See python#111140 See python#111139 * pythongh-111262: Re-add _PyDict_Pop() to have a C-API until a new public one is designed.
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
The `_PyErr_FormatFromCause` function is a private function, which was never documented. While it existed for a long time, it was removed in Python 3.13 [1]. Use instead the public function `PyErr_Format`, which is also part of the stable API. [1] python/cpython#106320 Signed-off-by: Arthur Zamarin <[email protected]>
…#111162) * pythongh-106320: Re-add _PyLong_FromByteArray(), _PyLong_AsByteArray() and _PyLong_GCD() to the public header files since they are used by third-party packages and there is no efficient replacement. See python#111140 See python#111139 * pythongh-111262: Re-add _PyDict_Pop() to have a C-API until a new public one is designed.
Python 3.13 moved some private C API functions to internal header files. See python/cpython#106320 for a general discussion on this (glad to see that gnureadline was at least listed as an affected PyPI package :-) ). These private functions affect us: - _Py_SetLocaleFromEnv -> pycore_pylifecycle.h (see python/cpython#106400) - _PyArg_CheckPositional, _PyArg_BadArgument -> pycore_modsupport.h (see python/cpython#110964) Since we can't include these anymore, patch the relevant declarations into the module code. The alternative (add the internal headers to this package) is much messier, as we would have to pull in most of those headers.
Over the years, we accumulated many private functions as part of the public C API header files. I propose to remove them: move them to the internal C API.
If many C extensions are affected by these removals, it's a sign that we should consider promoted used private functions as public functions: provide a better API, add error handling, write documentation, write tests.
Summary: My plan to clarify private vs public functions in Python 3.13
Private functions converted to public functions:
Discussions:
_Py_Identifier
_Py_c_abs()
)Notes:
Linked PRs
The text was updated successfully, but these errors were encountered: