]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-42202: Store func annotations as a tuple (GH-23316)
authorYurii Karabas <1998uriyyo@gmail.com>
Wed, 25 Nov 2020 10:43:18 +0000 (12:43 +0200)
committerGitHub <noreply@github.com>
Wed, 25 Nov 2020 10:43:18 +0000 (19:43 +0900)
commit7301979b23406220510dd2c7934a21b41b647119
tree296b337317ac71d34001c17f4b4b7bea918cbf6f
parent85c84920f511d0d73a133336daeaf715a022cd64
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>
Doc/library/dis.rst
Doc/whatsnew/3.10.rst
Lib/importlib/_bootstrap_external.py
Misc/NEWS.d/next/Core and Builtins/2020-11-16-18-13-07.bpo-42202.ZxenYD.rst [new file with mode: 0644]
Objects/funcobject.c
Python/ceval.c
Python/compile.c
Python/importlib_external.h