On Tue, Jan 12, 2021 at 12:56 PM Larry Hastings <[email protected]> wrote: > > It was a balancing act. Using an 64-byte empty dict per object with no > defined annotations seems so wasteful. And anything short of an empty dict, > you'd have to guard against. Current code already has to guard against > "__annotations__ aren't set" anyway, so I figured the cost of migrating to > checking a different condition would be small. And None is so cheap, and the > guard is so easy: > > if o.__annotations__: >
Does it have to be mutable? If not, maybe there could be a singleton "immutable empty dict-like object", in the same way that an empty tuple can be put anywhere that expects a sequence. That'd be as cheap as None (modulo a once-per-interpreter cost for the additional static object). ChrisA _______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/TWBC545KC7CK3DS5JZL4WBJM4BXZZBTI/ Code of Conduct: http://python.org/psf/codeofconduct/
