Saumitro Dasgupta <ether...@gmail.com> added the comment:

In my opinion, the main problem here is the element of surprise. Given a 
statement like this:

    foo.__annotations__['injected'] = bool

the expressed intent is "extend this object's annotations". It's surprising 
that it can sometimes result in accidental mutation of the base's annotations. 
This surprise may manifest downstream in other parts of the standard library 
(like dataclasses in the example above), which can be a bit cryptic.

As a performance optimization, it makes sense. However, the element of surprise 
probably can be improved upon. For instance:

- Explicitly disallow accidental mutation by presenting the parent's dict via a 
MappingProxy
- Use a "copy-on-write" mechanism

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40583>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to