8000 C API: Remove private functions from abstract.h · Issue #106084 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

C API: Remove private functions from abstract.h #106084

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

Closed
vstinner opened this issue Jun 25, 2023 · 6 comments
Closed

C API: Remove private functions from abstract.h #106084

vstinner opened this issue Jun 25, 2023 · 6 comments

Comments

@vstinner
Copy link
Member
vstinner commented Jun 25, 2023

Over the years, we accumulated many private functions as part of the public C API in abstract.h header file. I propose to remove them: move them to the internal C API.

Linked PRs

vstinner added a commit to vstinner/cpython that referenced this issue Jun 25, 2023
Remove old aliases which were kept backwards compatibility with
Python 3.8:

* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_FastCallDict()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyVectorcall_Function()

Update code which used these aliases to use new names.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 25, 2023
Remove old aliases which were kept backwards compatibility with
Python 3.8:

* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_FastCallDict()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyVectorcall_Function()

Update code which used these aliases to use new names.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 25, 2023
Remove old aliases which were kept backwards compatibility with
Python 3.8:

* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_FastCallDict()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyVectorcall_Function()

Update code which used these aliases to use new names.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 25, 2023
Remove _PySequence_BytesToCharpArray() and _Py_FreeCharPArray()
functions from the public C API: move these functions from
Objects/abstract.c to Modules/_posixsubprocess.c.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 25, 2023
Remove private _PySequence_BytesToCharpArray() and
_Py_FreeCharPArray() functions from the public C API: move these
functions from Objects/abstract.c to Modules/_posixsubprocess.c.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 25, 2023
Remove private _PySequence_BytesToCharpArray() and
_Py_FreeCharPArray() functions from the public C API: move these
functions from Objects/abstract.c to Modules/_posixsubprocess.c.
vstinner added a commit that referenced this issue Jun 26, 2023
Remove old aliases which were kept backwards compatibility with
Python 3.8:

* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_FastCallDict()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyVectorcall_Function()

Update code which used these aliases 
10000
to use new names.
vstinner added a commit that referenced this issue Jun 26, 2023
Remove private _PySequence_BytesToCharpArray() and
_Py_FreeCharPArray() functions from the public C API: move these
functions from Objects/abstract.c to Modules/_posixsubprocess.c.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 26, 2023
Remove _PyObject_HasLen() and _PySequence_IterSearch() functions from
the public C API: move them to the internal C API
(pycore_abstract.h).

Remove also unused pycore_initconfig.h include in typeobject.c.
vstinner added a commit that referenced this issue Jun 26, 2023
Remove _PyObject_HasLen() and _PySequence_IterSearch() functions from
the public C API: move them to the internal C API
(pycore_abstract.h).

No longer export these symbols (in libpython).

Remove also unused pycore_initconfig.h include in typeobject.c.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 26, 2023
Remove the following functions from the public C API:

* _PyObject_RealIsInstance()
* _PyObject_RealIsSubclass()
* _Py_add_one_to_index_F()
* _Py_add_one_to_index_C()

Move _PyObject_RealIsInstance() and _PyObject_RealIsSubclass() to the
internal C API (pycore_abstract.h) and no longer export their symbols
(in libpython).

Make _Py_add_one_to_index_F() and _Py_add_one_to_index_C() functions
static: no longer export them.
vstinner added a commit that referenced this issue Jun 26, 2023
Remove the following functions from the public C API:

* _PyObject_RealIsInstance()
* _PyObject_RealIsSubclass()
* _Py_add_one_to_index_F()
* _Py_add_one_to_index_C()

Move _PyObject_RealIsInstance() and _PyObject_RealIsSubclass() to the
internal C API (pycore_abstract.h) and no longer export their symbols
(in libpython).

Make _Py_add_one_to_index_F() and _Py_add_one_to_index_C() functions
static: no longer export them.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 27, 2023
Remove the following functions from the public C API:

* _Py_CheckFunctionResult()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdNoArgs()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_CallMethodIdOneArg()
* _PyObject_MakeTpCall()
* _PyObject_VectorcallMethodId()
* _PyStack_AsDict()

Move these functions to the internal C API (pycore_call.h).

No longer export the following functions:

* _PyObject_Call()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_Call_Prepend()
* _PyObject_FastCallDictTstate()
* _PyStack_AsDict()

The following functions are still exported for stdlib shared
extensions:

* _Py_CheckFunctionResult()
* _PyObject_MakeTpCall()
vstinner added a commit to vstinner/cpython that referenced this issue Jun 27, 2023
Remove the following functions from the public C API:

* _Py_CheckFunctionResult()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdNoArgs()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_CallMethodIdOneArg()
* _PyObject_MakeTpCall()
* _PyObject_VectorcallMethodId()
* _PyStack_AsDict()

Move these functions to the internal C API (pycore_call.h).

No longer export the following functions:

* _PyObject_Call()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_Call_Prepend()
* _PyObject_FastCallDictTstate()
* _PyStack_AsDict()

The following functions are still exported for stdlib shared
extensions:

* _Py_CheckFunctionResult()
* _PyObject_MakeTpCall()

Mark the following internal functions as extern:

* _PyStack_UnpackDict()
* _PyStack_UnpackDict_Free()
* _PyStack_UnpackDict_FreeNoDecRef()
vstinner added a commit to vstinner/cpython that referenced this issue Jun 27, 2023
Remove the following private functions from the public C API:

* _Py_CheckFunctionResult()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdNoArgs()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_CallMethodIdOneArg()
* _PyObject_MakeTpCall()
* _PyObject_VectorcallMethodId()
* _PyStack_AsDict()

Move these functions to the internal C API (pycore_call.h).

No longer export the following functions:

* _PyObject_Call()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_Call_Prepend()
* _PyObject_FastCallDictTstate()
* _PyStack_AsDict()

The following functions are still exported for stdlib shared
extensions:

* _Py_CheckFunctionResult()
* _PyObject_MakeTpCall()

Mark the following internal functions as extern:

* _PyStack_UnpackDict()
* _PyStack_UnpackDict_Free()
* _PyStack_UnpackDict_FreeNoDecRef()
vstinner added a commit that referenced this issue Jun 27, 2023
Remove the following private functions from the public C API:

* _Py_CheckFunctionResult()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdNoArgs()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_CallMethodIdOneArg()
* _PyObject_MakeTpCall()
* _PyObject_VectorcallMethodId()
* _PyStack_AsDict()

Move these functions to the internal C API (pycore_call.h).

No longer export the following functions:

* _PyObject_Call()
* _PyObject_CallMethod()
* _PyObject_CallMethodId()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_Call_Prepend()
* _PyObject_FastCallDictTstate()
* _PyStack_AsDict()

The following functions are still exported for stdlib shared
extensions:

* _Py_CheckFunctionResult()
* _PyObject_MakeTpCall()

Mark the following internal functions as extern:

* _PyStack_UnpackDict()
* _PyStack_UnpackDict_Free()
* _PyStack_UnpackDict_FreeNoDecRef()
@encukou
Copy link
Member
encukou commented Jun 30, 2023

Can we keep _PyObject_Vectorcall and such?
The underscore served the same purpose as today's unstable API, and so i think we should follow that process:

The old name should remain available until the new public name is deprecated or removed. There’s no need to deprecate the old name (it was unstable to begin with), but there’s also no need to break working code just because some function is now ready for a wider audience.

The #define is not a big maintenance burden, and there's no reason to punish early adopters or people who want easier compatibility with 3.8.

@encukou encukou reopened this Jun 30, 2023
@vstinner
Copy link
Member Author

I would like to reduce the size of the C API. Aliases are causing a maintenance burden:

  • Users have to decide which API is the "good one"
  • Old APIs may have to be documented and tested (these aliases are in the docs)
  • Other Python implementations have to implement it just because some C extensions use them: not all Python implementations can implement aliases with #define.
  • Macros are not available in C extensions which don't use the header file but use directly symbols: macros are bad, see https://peps.python.org/pep-0670/

A minority of project still refer to these old aliases. A code search on PyPI top 5,000 projects find matches in 8 projects:

  • debugpy (1.6.7)
  • iteration_utilities (0.11.0)
  • mypy (1.2.0)
  • orjson (3.8.10)
  • ptvsd (4.3.2)
  • pydevd (2.9.5)
  • scipy (1.10.1)
  • time-machine (2.9.0)
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/_uarray_dispatch.cxx: py_ref::steal(Q_PyObject_Vectorcall(cls, nullptr, 0, nullptr));
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/_uarray_dispatch.cxx: auto res = py_ref::steal(Q_PyObject_VectorcallMethod(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/_uarray_dispatch.cxx: res = py_ref::steal(Q_PyObject_Vectorcall(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/_uarray_dispatch.cxx: result = py_ref::steal(Q_PyObject_VectorcallMethod(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/_uarray_dispatch.cxx: py_ref ref = py_ref::steal(Q_PyObject_Vectorcall(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/_uarray_dispatch.cxx: auto res = py_ref::steal(Q_PyObject_VectorcallMethod(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: PyObject * Q_PyObject_Vectorcall(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: PyObject * ret = Q_PyObject_VectorcallDict(callable, args, nargs, dict);
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: return _PyObject_Vectorcall(callable, args, nargsf, kwnames);
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: PyObject * Q_PyObject_VectorcallDict(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: return _PyObject_FastCallDict(callable, (PyObject **)args, nargs, kwdict);
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: PyObject * Q_PyObject_VectorcallMethod(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: Q_PyObject_Vectorcall(callable, &args[1], nargsf - 1, kwnames);
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.cxx: PyObject * result = Q_PyObject_Vectorcall(callable, args, nargsf, kwnames);
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.h: PyObject * Q_PyObject_Vectorcall(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.h: PyObject * Q_PyObject_VectorcallDict(
PYPI-2023-04-13/scipy-1.10.1.tar.gz: scipy-1.10.1/scipy/_lib/_uarray/vectorcall.h: PyObject * Q_PyObject_VectorcallMethod(

PYPI-2023-04-13/debugpy-1.6.7.zip: debugpy-1.6.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_custom_pyeval_settrace_common.hpp: _PyObject_FastCallDict* pyObject_FastCallDict;
PYPI-2023-04-13/debugpy-1.6.7.zip: debugpy-1.6.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_settrace.hpp: DEFINE_PROC_NO_CHECK(pyObject_FastCallDict, _PyObject_FastCallDict*, "_PyObject_FastCallDict", 530);
PYPI-2023-04-13/debugpy-1.6.7.zip: debugpy-1.6.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_settrace.hpp: DEFINE_PROC_NO_CHECK(pyObject_FastCallDict, _PyObject_FastCallDict*, "PyObject_VectorcallDict", 533);
PYPI-2023-04-13/debugpy-1.6.7.zip: debugpy-1.6.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_settrace.hpp: pyObject_FastCallDict = reinterpret_
8000
cast<_PyObject_FastCallDict*>(&PyObject_FastCallDictCustom);
PYPI-2023-04-13/debugpy-1.6.7.zip: debugpy-1.6.7/src/debugpy/_vendored/pydevd/pydevd_attach_to_process/common/py_utils.hpp: typedef PyObject * (_PyObject_FastCallDict)(

PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/lib-rt/pythonsupport.h: result = _PyObject_FastCallDict(func, NULL, 0, kwds);
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/primitives/generic_ops.py: c_function_name="_PyObject_Vectorcall",
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r7 = _PyObject_Vectorcall(r4, r6, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r8 = _PyObject_Vectorcall(r5, r7, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r10 = _PyObject_Vectorcall(r7, r9, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r9 = _PyObject_Vectorcall(r6, r8, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r6 = _PyObject_Vectorcall(r3, r5, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r7 = _PyObject_Vectorcall(r4, r6, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r15 = _PyObject_Vectorcall(r12, r14, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r7 = _PyObject_Vectorcall(r4, r6, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r16 = _PyObject_Vectorcall(r13, r15, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r24 = _PyObject_Vectorcall(r21, r23, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r7 = _PyObject_Vectorcall(r4, r6, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r9 = _PyObject_Vectorcall(r6, r8, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r19 = _PyObject_Vectorcall(r16, r18, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r29 = _PyObject_Vectorcall(r26, r28, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r10 = _PyObject_Vectorcall(r7, r9, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r7 = _PyObject_Vectorcall(r4, r6, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r9 = _PyObject_Vectorcall(r6, r8, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r9 = _PyObject_Vectorcall(r5, r8, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r31 = _PyObject_Vectorcall(r28, r30, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r31 = _PyObject_Vectorcall(r28, r30, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r22 = _PyObject_Vectorcall(r19, r21, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r25 = _PyObject_Vectorcall(r22, r24, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r13 = _PyObject_Vectorcall(r10, r12, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r8 = _PyObject_Vectorcall(r5, r7, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r17 = _PyObject_Vectorcall(r14, r16, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r9 = _PyObject_Vectorcall(r6, r8, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r20 = _PyObject_Vectorcall(r17, r19, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r11 = _PyObject_Vectorcall(r8, r10, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r23 = _PyObject_Vectorcall(r20, r22, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r23 = _PyObject_Vectorcall(r20, r22, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r25 = _PyObject_Vectorcall(r22, r24, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r26 = _PyObject_Vectorcall(r23, r25, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r27 = _PyObject_Vectorcall(r24, r26, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r9 = _PyObject_Vectorcall(r6, r8, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-match.test: r13 = _PyObject_Vectorcall(r10, r12, 1, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-vectorcall.test: r0 = _PyObject_Vectorcall(c, 0, 0, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-vectorcall.test: r5 = _PyObject_Vectorcall(c, r4, 2, 0)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-vectorcall.test: r4 = _PyObject_Vectorcall(c, r2, 0, r3)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-vectorcall.test: r11 = _PyObject_Vectorcall(c, r9, 1, r10)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/irbuild-vectorcall.test: r10 = _PyObject_Vectorcall(r6, r8, 1, r9)
PYPI-2023-04-13/mypy-1.2.0.tar.gz: mypy-1.2.0/mypyc/test-data/refcount.test: r3 = _PyObject_Vectorcall(f, r2, 1, 0)

PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/local_dependencies/pyo3-ffi/src/cpython/abstract_.rs: pub unsafe fn _PyObject_VectorcallTstate(
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/local_dependencies/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(PyThreadState_GET(), callable, args, nargsf, kwnames)
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/local_dependencies/pyo3-ffi/src/cpython/abstract_.rs: #[cfg_attr(all(not(PyPy), not(Py_3_9)), link_name = "_PyObject_VectorcallDict")]
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/local_dependencies/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(tstate, func, args, nargs as size_t, std::ptr::null_mut())
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/local_dependencies/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/local_dependencies/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(tstate, func, args, nargsf as size_t, std::ptr::null_mut())
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs: pub unsafe fn _PyObject_VectorcallTstate(
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(PyThreadState_GET(), callable, args, nargsf, kwnames)
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs: #[cfg_attr(all(not(PyPy), not(Py_3_9)), link_name = "_PyObject_VectorcallDict")]
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(tstate, func, args, nargs as size_t, std::ptr::null_mut())
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(
PYPI-2023-04-13/orjson-3.8.10.tar.gz: orjson-3.8.10/include/pyo3/pyo3-ffi/src/cpython/abstract_.rs: _PyObject_VectorcallTstate(tstate, func, args, nargsf as size_t, std::ptr::null_mut())

PYPI-2023-04-13/pydevd-2.9.5.tar.gz: pydevd-2.9.5/pydevd_attach_to_process/common/py_custom_pyeval_settrace_common.hpp: _PyObject_FastCallDict* pyObject_FastCallDict;
PYPI-2023-04-13/pydevd-2.9.5.tar.gz: pydevd-2.9.5/pydevd_attach_to_process/common/py_settrace.hpp: DEFINE_PROC_NO_CHECK(pyObject_FastCallDict, _PyObject_FastCallDict*, "_PyObject_FastCallDict", 530);
PYPI-2023-04-13/pydevd-2.9.5.tar.gz: pydevd-2.9.5/pydevd_attach_to_process/common/py_settrace.hpp: DEFINE_PROC_NO_CHECK(pyObject_FastCallDict, _PyObject_FastCallDict*, "PyObject_VectorcallDict", 533);
PYPI-2023-04-13/pydevd-2.9.5.tar.gz: pydevd-2.9.5/pydevd_attach_to_process/common/py_settrace.hpp: pyObject_FastCallDict = reinterpret_cast<_PyObject_FastCallDict*>(&PyObject_FastCallDictCustom);
PYPI-2023-04-13/pydevd-2.9.5.tar.gz: pydevd-2.9.5/pydevd_attach_to_process/common/py_utils.hpp: typedef PyObject * (_PyObject_FastCallDict)(

PYPI-2023-04-13/ptvsd-4.3.2.zip: ptvsd-4.3.2/src/ptvsd/_vendored/pydevd/pydevd_attach_to_process/common/py_settrace.hpp: DEFINE_PROC(pyObject_FastCallDict, _PyObject_FastCallDict*, "_PyObject_FastCallDict", 530);
PYPI-2023-04-13/ptvsd-4.3.2.zip: ptvsd-4.3.2/src/ptvsd/_vendored/pydevd/pydevd_attach_to_process/common/py_settrace_37.hpp: _PyObject_FastCallDict* pyObject_FastCallDict;
PYPI-2023-04-13/ptvsd-4.3.2.zip: ptvsd-4.3.2/src/ptvsd/_vendored/pydevd/pydevd_attach_to_process/common/py_utils.hpp: typedef PyObject * (_PyObject_FastCallDict)(

PYPI-2023-04-13/time-machine-2.9.0.tar.gz: time-machine-2.9.0/src/_time_machine.c: result = _PyObject_Vectorcall(time_machine_now, args, nargs, kwnames);

PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/chained.c: PyObject *temp = PyIU_PyObject_Vectorcall(PyTuple_GET_ITEM(self->funcs, 0), args, nargsf, kwnames);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/chained.c: PyObject *temp = PyIU_PyObject_Vectorcall(func, args, nargsf, kwnames);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/complement.c: temp = PyIU_PyObject_Vectorcall(((PyIUObject_Complement *)obj)->func, args, nargsf, kwnames);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/flip.c: return PyIU_PyObject_Vectorcall(self->func, args, n_pos_args, kwnames);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/flip.c: result = PyIU_PyObject_Vectorcall(self->func, stack, n_pos_args, kwnames);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/helper.h: PyIU_PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) {
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/helper.h: return _PyObject_Vectorcall(callable, args, nargsf, kwnames);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/helper.h: return _PyObject_Vectorcall(callable, args, 1, NULL);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/helper.h: return PyIU_PyObject_Vectorcall(callable, args, 2, NULL);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/packed.c: result = PyIU_PyObject_Vectorcall(self->func, stack, num_packed_args, kwnames);
PYPI-2023-04-13/iteration_utilities-0.11.0.tar.gz: iteration_utilities-0.11.0/src/iteration_utilities/_iteration_utilities/partial.c: result = PyIU_PyObject_Vectorcall(self->fn, stack, n_final_args, final_kwnames);

Fixing these projects is easy: it's just about removing an underscore prefix.

@encukou
Copy link
Member
encukou commented Jun 30, 2023

Users have to decide which API is the "good one"

in this case, it's obvious.

Old APIs may have to be documented and tested (these aliases are in the docs)

Oh, let's remove the docs!
I don't think we need to test simple aliases.

Other Python implementations have to implement it just because some C extensions use them: not all Python implementations can implement aliases with #define.

That's OK, IMO.
If the implementation is close to CPython, it needs to do much weirder things.
If it's not that close, and users typically need some porting to use it, the users need to remove the underscore.

Macros are not available in C extensions which don't use the header file but use directly symbols: macros are bad, see https://peps.python.org/pep-0670/

Yes, you shouldn't use them and sometimes you can't. That doesn't apply to code that's already using them.

@vstinner
Copy link
Member Author
vstinner commented Jul 1, 2023

Just a reminder from the C API doc:

Names prefixed by an underscore, such as _Py_InternalState, are private API that can change without notice even in patch releases. If you need to use this API, consider reaching out to CPython developers to discuss adding public API for your use case.

I don't see why these aliases would be treated differently.

By the way, in this case, there is already a public API for these private functions. So migrating code is trivial.

@encukou
Copy link
Member
encukou commented Jul 3, 2023

I don't see why these aliases would be treated differently.

Because the API was added before that note was added to the docs. Those who used the API might not have seen the note, and it is unfair of us to change the rules later.
If users read the docs now they should follow it, and it's not useful to add legacy considerations to user-facing docs. But core devs should follow the devguide and PEPs, and be conservative if there's any doubt.

@vstinner
Copy link
Member Author

I close this issue to continue the discussion in the more complete issue #106320.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0