SIGN IN SIGN UP

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>
Y
Yurii Karabas committed
7301979b23406220510dd2c7934a21b41b647119
Parent: 85c8492
Committed by GitHub <noreply@github.com> on 11/25/2020, 10:43:18 AM