Closed
Description
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:
- PyLong_AsInt(): issue [C API] Add PyLong_AsInt() public function #108444
- Py_IsFinalizing(): PR gh-108014: Add Py_IsFinalizing() function #108032
-
Discussions:
- (pssst) Let’s treat all API in public headers as public
- list of PyPI affected projects
- C API: How much private is the private _Py_IDENTIFIER() API? --
_Py_Identifier
- _Py_c_xxx complex functions (ex:
_Py_c_abs()
) - PR gh-107137: Add _PyTupleBuilder API to the internal C API #107139: Add _PyTupleBuilder API to the internal C API
-
Notes:
- While being private, _PyBytes_Resize() and _PyTuple_Resize() are documented
- The private _PyCrossInterpreterData API is used by 3rd party project on PyPI: gh-106320: Remove private _PyCrossInterpreterData API #107068 (comment). I closed my PR gh-106320: Remove private _PyCrossInterpreterData API #107068.
Linked PRs
- gh-106320: Remove _PyInterpreterState_Get() alias #106321
- gh-106320: Remove private _PyTraceMalloc C API functions #106324
- gh-106320: Remove private _PyInterpreterState functions #106325
- gh-106320: Remove private _PyInterpreterState functions #106335
- gh-106320: Use _PyInterpreterState_GET() #106336
- gh-106320: Add pycore_complexobject.h header file #106339
- gh-106320: _testcapi avoids private _PyUnicode_EqualToASCIIString() #106341
- gh-106320: Move _PyUnicodeWriter to the internal C API #106342
- gh-106320: Create pycore_moduleobject.h header file #106355
- gh-106320: Remove private _PyErr C API functions #106356
- gh-106320: Remove more private _PyUnicode C API functions #106382
- gh-106320: Remove private _PyImport C API functions #106383
- gh-106320: Remove more private _PyUnicode C API functions (#106382) #106385
- gh-106320: Fix _PyImport_GetModuleAttr() declaration #106386
- gh-106320: Remove _PyUnicode_TransformDecimalAndSpaceToASCII() #106398
- gh-106320: Remove _PyBytesWriter C API #106399
- gh-106320: Remove private pylifecycle.h functions #106400
- gh-106320: Add missing #include in _winapi.c #106417
- gh-106320: Remove _PyInterpreterState_HasFeature() #106425
- gh-106320: Fix specialize.c compilation by including pycore_pylifecycle.h #106434
- gh-106320: Remove private _PyUnicode_AsString() alias #107021
- gh-106320: Move private _PyHash API to the internal C API #107026
- gh-106320: Document private C API removal in What's New 3.13 #107027
- gh-106320: Move _PyNone_Type to the internal C API #107030
- gh-106320: Move private _PyGen API to the internal C API #107032
- gh-106320: Remove _PyOS_ReadlineTState API #107034
- gh-106320: Remove _Py_SwappedOp from the C API #107036
- gh-106320: Move private _PySet API to the internal API #107041
- gh-106320: Remove private _PyInterpreterID C API #107053
- gh-106320: Move _PyMethodWrapper_Type to internal C API #107064
- gh-106320: Remove private _PyCrossInterpreterData API #107068
- gh-106320: Remove private _PyModule API #107070
- gh-106320: Remove _PyFunction_Vectorcall() API #107071
- gh-106320: Remove _PyIsSelectable_fd() C API #107142
- gh-106320: Remove _PyTuple_MaybeUntrack() C API #107143
- gh-106320: Remove _PyBytes_Join() C API #107144
- gh-106320: Remove private _PyDict C API #107145
- gh-106320: Remove private _PyObject C API #107147
- gh-106320: Remove private _PyObject C API #107159
- gh-106320: Remove private _PyUnicode C API #107185
- gh-106320: Remove private _PyMem API #107187
- gh-106320: Remove _PyDict_GetItemStringWithError() function #108313
- gh-106320: Remove private PyLong C API functions #108429
- gh-106320: Remove private float C API functions #108430
- gh-106320: Remove private _PyManagedBuffer_Type #108431
- gh-106320: Remove private _PyEval function #108433
- gh-106320: Remove private _PyContext_NewHamtForTests() #108434
- gh-106320: Remove private _PyDict function #108449
- gh-106320: Remove private _PyList function #108451
- gh-106320: Remove private _PySys functions #108452
- gh-106320: Remove private _PyTraceback functions #108453
- gh-106320: Remove private _PyLong converter functions #108499
- gh-106320: Remove private _PyLong_FileDescriptor_Converter() #108503
- gh-106320: Remove private AC converter functions #108505
- gh-106320: Remove private _Py_Identifier API #108593
- gh-106320: Remove _PyAnextAwaitable_Type from the public C API #108597
- gh-106320: Remove private pythonrun API #108599
- gh-106320: Remove private _PyType_Lookup() function #108600
- gh-106320: Remove private _PyThread_at_fork_reinit() function #108601
- gh-106320: Remove private _Py_UniversalNewlineFgetsWithSize() #108602
- gh-106320: Remove private _PyGILState_GetInterpreterStateUnsafe() #108603
- gh-106320: Remove private _PyLong_New() function #108604
- gh-106320: Remove private _PyOS_IsMainThread() function #108605
- gh-106320: Remove private _PyObject_GetState() #108606
- gh-106320: Remove private _PyErr_SetKeyError() #108607
- gh-106320: Fix test_peg_generator: _Py_UniversalNewlineFgetsWithSize() #108609
- gh-106320: Remove private _Py_ForgetReference() #108664
- gh-106320: Don't export _Py_ForgetReference() function #108712
- gh-106320: Remove private _PyErr_ChainExceptions() #108713
- gh-106320: winconsoleio.c includes pycore_pyerrors.h #108720
- gh-106320: Remove private _PyLong_IsCompact() function #108742
- gh-106320: Remove private _PyLong_Sign() #108743
- gh-106320: Remove private _PyErr_WriteUnraisableMsg() #108863
- gh-106320: Re-add some PyLong/PyDict C-API functions #111162
- gh-111262: Add PyDict_Pop() function [with default value] #111939
- gh-106320: Document replacement for removed C API #128787
- gh-106320: Document private C APIs promoted to public C API #128788
- [3.13] gh-106320: Document replacement for removed C API (GH-128787) #128837