This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author carljm
Recipients Omer.Katz, alex, carljm, eric.araujo, madison.may, pitrou, pydanny, r.david.murray, rhettinger, serhiy.storchaka, vstinner
Date 2016-11-10.21:50:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1478814619.47.0.0660407889892.issue21145@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-11-10 21:50:19carljmsetrecipients: + carljm, rhettinger, pitrou, vstinner, pydanny, eric.araujo, alex, r.david.murray, serhiy.storchaka, madison.may, Omer.Katz
2016-11-10 21:50:19carljmsetmessageid: <1478814619.47.0.0660407889892.issue21145@psf.upfronthosting.co.za>
2016-11-10 21:50:19carljmlinkissue21145 messages
2016-11-10 21:50:19carljmcreate