> 3. It doesn't add a name constant. Instead it uses a name from the names list (which already has to contain this name).
This PR moves the constant for the name from `co_names` to `co_consts`. There is no duplication.
>>> def f():
... class C:
... a : 1
(It does add __annotations__ to `co_names`, but that seems reasonable to me)
Current:
>>> f.__code__.co_consts[1].co_names
('__name__', '__module__', '__qualname__', 'a')
>>> f.__code__.co_consts[1].co_consts
('f.<locals>.C', 1, None)
With PR 5181:
>>> f.__code__.co_consts[1].co_names
('__name__', '__module__', '__qualname__', '__annotations__')
>>> f.__code__.co_consts[1].co_consts
('f.<locals>.C', 1, 'a', None) |