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 rhettinger
Recipients Omer.Katz, alex, carljm, eric.araujo, madison.may, ncoghlan, pitrou, pydanny, r.david.murray, rhettinger, serhiy.storchaka, vstinner
Date 2018-05-15.23:55:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1526428540.64.0.682650639539.issue21145@psf.upfronthosting.co.za>
In-reply-to
Content
FWIW, over the past decade, I've used variants of CachedProperty a number of times and have often had issues that later required messing with its internals (needing a way to invalidate or clear the cache, mock patching the underlying function for testing, consistency between multiple cached properties cached in different threads, inability to run the method through a debugger, inadvertently killing logging or other instrumentation, moving the cache valued from an instance variables to an external weakref dictionary etc).

I proposed the idea of a CachedProperty in descriptor tutorials over a decade ago.  Since then, I've grown wary of the idea of making them available for general use.  Instead, we're better with a recipe that someone can use to build their understanding and then customize as necessary.  The basic recipe is simple so there isn't much of a value add by putting this in the standard library.

If we want to add another property() variant, the one I've had the best luck with is CommonProperty() which lets you re-use the same getter and setter methods for multiple properties (the name of the property variable gets passed in as the first argument).
History
Date User Action Args
2018-05-15 23:55:40rhettingersetrecipients: + rhettinger, ncoghlan, pitrou, vstinner, carljm, pydanny, eric.araujo, alex, r.david.murray, serhiy.storchaka, madison.may, Omer.Katz
2018-05-15 23:55:40rhettingersetmessageid: <1526428540.64.0.682650639539.issue21145@psf.upfronthosting.co.za>
2018-05-15 23:55:40rhettingerlinkissue21145 messages
2018-05-15 23:55:40rhettingercreate