tracking collection modification

Paul Boddie paul at boddie.org.uk
Mon Sep 8 15:27:35 CEST 2008


On 7 Sep, 12:54, usenet.tolo... at gmail.com wrote:
> I'm working on a remote object system, something kinda like Pyro.
> For the purposes of caching I need to be able to tell if a given
> dict / list / set has been modified.
> Ideally what I'd like is for them to have a modification count
> variable that increments every time the particular collection is
> modified. Unfortunately I can't find anything like that and since this
> needs to work for the regular normal list / dict / set objects
> subclassing them to add the modification count isn't useful.

What you appear to need here is some kind of proxying solution - a
layer which records accesses to the objects, distinct from the objects
themselves. I believe that the PyPy project provides something of this
nature:

http://codespeak.net/pypy/dist/pypy/doc/objspace-proxies.html

Paul



More information about the Python-list mailing list