Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

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).

----------
versions: +Python 3.8 -Python 3.7

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

Reply via email to