Skip to content
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

Use static inline function Py_EnterRecursiveCall() #91988

Merged
merged 1 commit into from
May 4, 2022
Merged

Use static inline function Py_EnterRecursiveCall() #91988

merged 1 commit into from
May 4, 2022

Conversation

vstinner
Copy link
Member

Currently, calling Py_EnterRecursiveCall() and
Py_LeaveRecursiveCall() may use a function call or a static inline
function call, depending if the internal pycore_ceval.h header file
is included or not. Use a different name for the static inline
function to ensure that the static inline function is always used in
Python internals for best performance. Similar approach than
PyThreadState_GET() (function call) and _PyThreadState_GET() (static
inline function).

  • Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate()
  • Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate()
  • pycore_ceval.c: Rename Py_EnterRecursiveCall() to
    _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and
    _Py_LeaveRecursiveCall()

@vstinner
Copy link
Member Author

I'm not convinced that the performance of the static inline function is worth it. Maybe it can just be removed to only keep the variant with a tstate parameter?

Currently, calling Py_EnterRecursiveCall() and
Py_LeaveRecursiveCall() may use a function call or a static inline
function call, depending if the internal pycore_ceval.h header file
is included or not. Use a different name for the static inline
function to ensure that the static inline function is always used in
Python internals for best performance. Similar approach than
PyThreadState_GET() (function call) and _PyThreadState_GET() (static
inline function).

* Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate()
* Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate()
* pycore_ceval.c: Rename Py_EnterRecursiveCall() to
  _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and
  _Py_LeaveRecursiveCall()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants