[Python-Dev] Mutable object change flag
Raymond Hettinger
python@rcn.com
Sun, 12 May 2002 20:41:26 -0400
As an early step toward implementing an observer pattern, I built a simpler
protocol that sets a mutable object's attribute to zero whenever the object
changes state.
If you guys would like to try it out, see the patch at
www.python.org/sf/555251. I tried to time the cost of frequent attribute
resets but they were so fast I couldn't produce a measurable difference.
Raymond Hettinger
Here's a sample session:
>>> a = list('abcd')
>>> a.cachevalid
0
>>> a.cachevalid=1
>>> a.cachevalid
1
>>> a[2] = 'k'
>>> a.cachevalid
0