[Patches] [ python-Patches-555251 ] Mutable object change flag
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 07 Oct 2002 14:32:31 -0700
Patches item #555251, was opened at 2002-05-13 02:22
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=555251&group_id=5470
Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 1
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: Mutable object change flag
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2002-10-07 23:32
Message:
Logged In: YES
user_id=21627
Raymond, are you still interested in this approach?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=555251&group_id=5470