Author vstinner
Recipients vstinner
Date 2020-03-12.17:40:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Python has an internal function to get the frame of the PyThreadState:

/* hook for PyEval_GetFrame(), requested for Psyco */
#define _PyThreadState_GetFrame _PyRuntime.gilstate.getframe

It is used by the public function PyEval_GetFrame() for example.

The indirection was added in 2002 by:

commit 019a78e76d3542d4d56a08015e6980f8c8aeaba1
Author: Michael W. Hudson <>
Date:   Fri Nov 8 12:53:11 2002 +0000

    Assorted patches from Armin Rigo:
    [ 617309 ] getframe hook (Psyco #1)
    [ 617311 ] Tiny profiling info (Psyco #2)
    [ 617312 ] debugger-controlled jumps (Psyco #3)
    These are forward ports from 2.2.2.

... but psyco is outdated for a very long time (superseded by PyPy which is no longer based on CPython). Is it time to drop _PyThreadState_GetFrame() (which became _PyRuntime.gilstate.getframe in the meanwhile)?

Or if we keep it, we should use it rather accessing directly PyThreadState.frame (read or write).

See also PEP 523 "Adding a frame evaluation API to CPython" and a recent discussion on this PEP: bpo-38500.
Date User Action Args
2020-03-12 17:40:48vstinnersetrecipients: + vstinner
2020-03-12 17:40:48vstinnersetmessageid: <>
2020-03-12 17:40:48vstinnerlinkissue39946 messages
2020-03-12 17:40:48vstinnercreate