Message280547
How do you propose that slots should be supported?
Part of the value of cached_property is that cached access is a normal Python attribute access with no function call overhead. I am not interested in adding support for slots if it loses that benefit. I would not use such an implementation myself.
I may be missing some option, but I can't see how to add slots support without losing that benefit, because it requires the ability to store an instance attribute under the same name as the descriptor, taking advantage of the fact that instance dict overrides a non-data descriptor.
This implementation of cached_property has been in wide use in multiple very popular projects for many years. The fact that none of those implementations have ever needed to add slots support suggests that it isn't actually that important.
If you have an idea for how to support slots without making cached_property less valuable for the common case, please share it and I am willing to implement it.
Otherwise, I propose that this implementation which is already proved in wide usage should be added to the stdlib; I can add a documentation note that objects with slots are not supported. If there is demand for cached_property_with_slots, it can be added separately. |
|
Date |
User |
Action |
Args |
2016-11-10 21:50:19 | carljm | set | recipients:
+ carljm, rhettinger, pitrou, vstinner, pydanny, eric.araujo, alex, r.david.murray, serhiy.storchaka, madison.may, Omer.Katz |
2016-11-10 21:50:19 | carljm | set | messageid: <1478814619.47.0.0660407889892.issue21145@psf.upfronthosting.co.za> |
2016-11-10 21:50:19 | carljm | link | issue21145 messages |
2016-11-10 21:50:19 | carljm | create | |
|