From c9b2d228c5fc147c18f8e43ecdbbb6c975b8cccf Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Mon, 9 May 2022 18:18:53 +0800 Subject: [PATCH 1/3] Add a note about ``sys._getframe`` compatibility in 3.11 whatsnew --- Doc/whatsnew/3.11.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 793c92aaea4165..105b12853e02f9 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -891,11 +891,17 @@ holds execution information. The following are new frame optimizations: - Streamlined the internal frame struct to contain only essential information. Frames previously held extra debugging and memory management information. -Old-style frame objects are now created only when required by debuggers. For -most user code, no frame objects are created at all. As a result, nearly all +Old-style frame objects are now created only when required by debuggers. +For most user code, no frame objects are created at all. As a result, nearly all Python functions calls have sped up significantly. We measured a 3-7% speedup in pyperformance. +.. note:: + Python frame introspection functions like ``inspect.currentframe`` + or ``sys._getframe`` still work. However, they will not enjoy the + performance improvements. This change is backwards compatible. + + (Contributed by Mark Shannon in :issue:`44590`.) .. _inline-calls: From f8508aab5a0bf8b00fe031c736465fbc659ef556 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Mon, 9 May 2022 18:20:29 +0800 Subject: [PATCH 2/3] Minimise diff --- Doc/whatsnew/3.11.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 105b12853e02f9..cc087e55913658 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -891,8 +891,8 @@ holds execution information. The following are new frame optimizations: - Streamlined the internal frame struct to contain only essential information. Frames previously held extra debugging and memory management information. -Old-style frame objects are now created only when required by debuggers. -For most user code, no frame objects are created at all. As a result, nearly all +Old-style frame objects are now created only when required by debuggers. For +most user code, no frame objects are created at all. As a result, nearly all Python functions calls have sped up significantly. We measured a 3-7% speedup in pyperformance. From 1edcfdbfcfd9c26b18c65c345789e1afb8cf26a3 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Mon, 9 May 2022 20:22:04 +0800 Subject: [PATCH 3/3] Address Kumar's code review --- Doc/whatsnew/3.11.rst | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index cc087e55913658..6d894bc183256b 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -891,16 +891,11 @@ holds execution information. The following are new frame optimizations: - Streamlined the internal frame struct to contain only essential information. Frames previously held extra debugging and memory management information. -Old-style frame objects are now created only when required by debuggers. For -most user code, no frame objects are created at all. As a result, nearly all -Python functions calls have sped up significantly. We measured a 3-7% speedup -in pyperformance. - -.. note:: - Python frame introspection functions like ``inspect.currentframe`` - or ``sys._getframe`` still work. However, they will not enjoy the - performance improvements. This change is backwards compatible. - +Old-style frame objects are now created only when requested by debuggers or +by Python introspection functions such as ``sys._getframe`` or +``inspect.currentframe``. For most user code, no frame objects are +created at all. As a result, nearly all Python functions calls have sped +up significantly. We measured a 3-7% speedup in pyperformance. (Contributed by Mark Shannon in :issue:`44590`.)