[issue37949] Create empty __annotations__ dictionaries lazily

Serhiy Storchaka report at bugs.python.org
Mon Aug 26 04:05:15 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Guido's Time Machine strikes back.

>>> import gc
>>> def f(): pass
... 
>>> gc.get_referents(f)
[<code object f at 0x7f45f5d366c0, file "<stdin>", line 1>, {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'gc': <module 'gc' (built-in)>, 'f': <function f at 0x7f45f5dd3b90>}, '__main__', None, 'f', 'f']
>>> f.__annotations__
{}
>>> gc.get_referents(f)
[<code object f at 0x7f45f5d366c0, file "<stdin>", line 1>, {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'gc': <module 'gc' (built-in)>, 'f': <function f at 0x7f45f5dd3b90>}, '__main__', None, 'f', {}, 'f']

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37949>
_______________________________________


More information about the Python-bugs-list mailing list