tracking collection modification

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • usenet.tolomea@gmail.com

    tracking collection modification

    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.
    I realize I could take a copy and then compare the copy to the
    original, but that's a fairly heavy handed approach and I was hoping
    for something light and fast.
    Does anyone have any suggestions on best to approach this?
  • usenet.tolomea@gmail.com

    #2
    Re: tracking collection modification

    On Sep 7, 8:54 pm, usenet.tolo...@ 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.
    I realize I could take a copy and then compare the copy to the
    original, but that's a fairly heavy handed approach and I was hoping
    for something light and fast.
    Does anyone have any suggestions on best to approach this?
    additionally I don't need to know if the things the list (etc)
    references have changed, only the list itself

    Comment

    • Diez B. Roggisch

      #3
      Re: tracking collection modification

      usenet.tolomea@ gmail.com wrote:
      On Sep 7, 8:54 pm, usenet.tolo...@ 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.
      >I realize I could take a copy and then compare the copy to the
      >original, but that's a fairly heavy handed approach and I was hoping
      >for something light and fast.
      >Does anyone have any suggestions on best to approach this?
      >
      additionally I don't need to know if the things the list (etc)
      references have changed, only the list itself
      No chance. E.g. ZODB is faced with the same problem and requires you to use
      certain collection implementations to make this work.

      And don't forget that such a scheme is hard to implement in the face of
      concurrent access by various clients - as client connection has to keep
      track of the last-modified-state separately.

      I'd say that for small to medium-sized collections, it's faster to just
      marshal them each time. Beyond that, make the heavy-handed checking - and
      offer dirty-state-aware collection classes one can use to optimize specific
      cases.

      Diez

      Comment

      • Paul Boddie

        #4
        Re: tracking collection modification

        On 7 Sep, 12:54, usenet.tolo...@ 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:



        Paul

        Comment

        Working...