Repository navigation
Use _Py_EnterRecursiveCall private API in _bisectmodule.c #101903
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Feb 14, 2023 Looks like the Public API functions
Lines 3066 to 3081 in 23751ed
/* Implement Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() as functions for the limited API. */ #undef Py_EnterRecursiveCall int Py_EnterRecursiveCall(const char *where) { return _Py_EnterRecursiveCall(where); } #undef Py_LeaveRecursiveCall void Py_LeaveRecursiveCall(void) { _Py_LeaveRecursiveCall(); } are just wrappers for the private static inline functions
cpython/Include/internal/pycore_ceval.h
Lines 135 to 147 in 7644935
static inline int _Py_EnterRecursiveCall(const char *where) { PyThreadState *tstate = _PyThreadState_GET(); return _Py_EnterRecursiveCallTstate(tstate, where); } static inline void _Py_LeaveRecursiveCallTstate(PyThreadState *tstate) { tstate->c_recursion_remaining++; } static inline void _Py_LeaveRecursiveCall(void) { PyThreadState *tstate = _PyThreadState_GET(); _Py_LeaveRecursiveCallTstate(tstate); } @gdementen - I don't see the harm in submitting a PR!
- addedextension-modulesC modules in the Modules dirC modules in the Modules dir
on Feb 15, 2023 - added a commit that references this issue
on Feb 21, 2023 As noted in #101931 (comment), this requires defining
_bisectmodule.cas a core module, which IMO requires a broader discussion.We deliberately make some stdlib extension modules use the public C API. As an (unrwritten) general rule, the modules in
Modules/Setup.bootstrap.inare built using the internal C API, whereas the modules inModules/Setup.stdlib.inshould preferably use the public C API.Suggesting to close this issue as not-planned.
Reacted by Gaëtan de Menten- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Feb 21, 2023 See also Eric's comments from similar API issues: #31376 (comment) and #31376 (comment)
- removedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Feb 21, 2023 Thanks @erlend-aasland
Reacted by Gaëtan de Menten- added a commit that references this issue
on Feb 23, 2023
Feature or enhancement
I just noticed the _bisectmodule.c is the only internal module using the Py_EnterRecursiveCall and Py_LeaveRecursiveCall public API functions instead of the private ones with underscores. For both consistency and a tiny performance enhancement, I think it would make sense to use the private API instead.
Pitch
I have a PR ready for this, but since I have no idea of what I am doing this might be completely bogus 😉.
Linked PRs