summaryrefslogtreecommitdiff
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorYurii Karabas <1998uriyyo@gmail.com>2020-11-25 12:43:18 +0200
committerGitHub <noreply@github.com>2020-11-25 19:43:18 +0900
commit7301979b23406220510dd2c7934a21b41b647119 (patch)
tree296b337317ac71d34001c17f4b4b7bea918cbf6f /Doc/whatsnew
parent85c84920f511d0d73a133336daeaf715a022cd64 (diff)
downloadcpython-git-7301979b23406220510dd2c7934a21b41b647119.tar.gz
bpo-42202: Store func annotations as a tuple (GH-23316)
Reduce memory footprint and improve performance of loading modules having many func annotations. >>> sys.getsizeof({"a":"int","b":"int","return":"int"}) 232 >>> sys.getsizeof(("a","int","b","int","return","int")) 88 The tuple is converted into dict on the fly when `func.__annotations__` is accessed first. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.10.rst11
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index c5efaaa504..704de8156f 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -388,6 +388,11 @@ Optimizations
for more details. (Contributed by Victor Stinner and Pablo Galindo in
:issue:`38980`)
+* Function parameters and their annotations are no longer computed at runtime,
+ but rather at compilation time. They are stored as a tuple of strings at the
+ bytecode level. It is now around 100% faster to create a function with parameter
+ annotations. (Contributed by Yurii Karabas and Inada Naoki in :issue:`42202`)
+
Deprecated
==========
@@ -461,6 +466,12 @@ Changes in the Python API
have been renamed to *exc*.
(Contributed by Zackery Spytz and Matthias Bussonnier in :issue:`26389`.)
+CPython bytecode changes
+========================
+
+* The ``MAKE_FUNCTION`` instruction accepts tuple of strings as annotations
+ instead of dictionary.
+ (Contributed by Yurii Karabas and Inada Naoki in :issue:`42202`)
Build Changes
=============