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.

classification
Title: Mutable object change flag
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: loewis, rhettinger
Priority: low Keywords: patch

Created on 2002-05-13 00:22 by rhettinger, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cache.dif rhettinger, 2002-05-13 00:22 Context diff for listobject.c and listobject.h
Messages (2)
msg40017 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-13 00:22
This patch is a proof-of-concept for marking state 
changes in mutable objects.  It is meant as a simpler, 
faster alternative to a full built-in observer pattern.

Here's the whole protocol:
Mutable objects choosing to implement the protocol 
provide a writable attribute, cachevalid, which is 
initialized to zero.  Upon any update to the object, 
the attribute is reset to zero.  Callers who set the 
attribute to one can later check to see if an update 
has occurred (as indicated by a zero).

>>> a = list('abcd')
>>> a.cachevalid
0
>>> a.cachevalid=1
>>> a.cachevalid
1
>>> a[2] = 'k'
>>> a.cachevalid
0

The proof-of-concept patch is implemented only for 
lists.  A production version would need to include 
dictionaries.

msg40018 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-10-07 21:32
Logged In: YES 
user_id=21627

Raymond, are you still interested in this approach?
History
Date User Action Args
2022-04-10 16:05:19adminsetgithub: 36596
2002-05-13 00:22:27rhettingercreate