Message217809
Unlike the other collections ABCs, MappingView and its subclasses (Keys|Items|Values)View don't define __slots__, so users inheriting them to take advantage of the mix-in methods get a __dict__ and __weakref__, even if they try to avoid it by declaring their own __slots__. This is sub-optimal (I don't think any library class should leave __slots__ undefined, but it's particularly bad when they're intended to be used a base classes).
I've attached a patch that defines __slots__ for all of them; MappingView explicitly declares its _mapping slot, and the rest declare no slots at all.
Only negative I can think of is that if the user provides their own __init__, doesn't call the super().__init__, and uses a different name than _mapping for whatever data structure they actually use, then there will be a pointer reserved for _mapping that never gets set. That said, if they don't define _mapping, none of the mix-in methods work anyway, so they may as well not inherit directly, and instead just use *View.register to become a virtual subclass. |
|
Date |
User |
Action |
Args |
2014-05-03 00:02:42 | josh.r | set | recipients:
+ josh.r |
2014-05-03 00:02:41 | josh.r | set | messageid: <1399075361.96.0.75684702655.issue21421@psf.upfronthosting.co.za> |
2014-05-03 00:02:41 | josh.r | link | issue21421 messages |
2014-05-03 00:02:41 | josh.r | create | |
|