Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40664

Re: Creating an object that can track when its attributes are modified

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <dihedral88888@googlemail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'attribute': 0.05; 'diff': 0.05; 'modified': 0.05; 'modify': 0.05; 'python': 0.09; '(it': 0.09; 'subclass': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr :python-list': 0.10; "wouldn't": 0.11; 'stack': 0.15; 'properties,': 0.16; 'subject:object': 0.16; 'subject:when': 0.16; 'using,': 0.16; 'utc,': 0.16; 'wrote:': 0.17; 'certainly': 0.17; 'trying': 0.21; 'explicit': 0.22; 'wednesday,': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'properties': 0.24; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'guess': 0.27; 'implemented': 0.27; 'chris': 0.28; 'comparison': 0.29; 'gather': 0.29; 'types.': 0.29; 'objects': 0.29; 'probably': 0.29; 'that.': 0.30; 'function': 0.30; 'could': 0.32; 'operations': 0.33; 'changed': 0.34; 'received:google.com': 0.34; 'list': 0.35; 'ben': 0.35; 'from:addr:googlemail.com': 0.35; 'too.': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'expensive': 0.36; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'perform': 0.38; 'store': 0.38; 'object': 0.38; 'skip:l 20': 0.38; 'several': 0.39; 'performance': 0.39; 'end': 0.40; 'burden': 0.65; 'differences': 0.65; 'goal': 0.74; '2013': 0.84; 'effectively,': 0.84; 'having,': 0.84; 'snapshot': 0.84; 'snapshots': 0.84; 'subject:its': 0.84
X-Received by 10.50.6.135 with SMTP id b7mr2333078iga.9.1362604061158; Wed, 06 Mar 2013 13:07:41 -0800 (PST)
Newsgroups comp.lang.python
Date Wed, 6 Mar 2013 13:07:40 -0800 (PST)
In-Reply-To <5c776c70-aa7d-4b2e-ad7b-54392793c607@googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw
References <b281a2a6-5822-45c7-bf69-c80c738ef92c@googlegroups.com> <mailman.2949.1362586985.2939.python-list@python.org> <5c776c70-aa7d-4b2e-ad7b-54392793c607@googlegroups.com>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 123.192.32.215
MIME-Version 1.0
Subject Re: Creating an object that can track when its attributes are modified
From 88888 Dihedral <dihedral88888@googlemail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.2961.1362604069.2939.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362604069 news.xs4all.nl 6892 [2001:888:2000:d::a6]:39974
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40664

Show key headers only | View raw


Ben Sizer於 2013年3月7日星期四UTC+8上午12時56分09秒寫道:
> On Wednesday, 6 March 2013 16:22:56 UTC, Chris Angelico  wrote:
> 
> > 
> 
> > Effectively, you would need to have a
> 
> > subclass of list/dict/tuple/whatever that can respond to the change. 
> 
> 
> 
> This is certainly something I'd be interested in having, but I guess that would be fragile since the user would have the burden of having to remember to use those types.
> 
> 
> 
> > What's the goal of this class? Can you achieve the same thing by
> 
> > using, perhaps, a before-and-after snapshot of a JSON-encoded form of
> 
> > the object?
> 
> > 
> 
> 
> 
> I need to be able to perform complex operations on the object that may modify several properties, and then gather the properties at the end as an efficient way to see what has changed and to store those changes. Any comparison of before-and-after snapshots could work in theory, but in practice it could be expensive to produce the snapshots on larger objects and probably expensive to calculate the differences that way too. Performance is important so I would probably just go for an explicit function call to mark an attribute as having been modified rather than trying to do a diff like that. (It wouldn't work for rollbacks, but I can accept that.)
> 
> 
> 
> -- 
> 
> Ben Sizer
Please hook a stack implemented as a list in python  to every property 
of the object  that you want to track down.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Creating an object that can track when its attributes are modified Ben Sizer <kylotan@gmail.com> - 2013-03-06 08:07 -0800
  Re: Creating an object that can track when its attributes are modified Chris Angelico <rosuav@gmail.com> - 2013-03-07 03:22 +1100
    Re: Creating an object that can track when its attributes are modified Ben Sizer <kylotan@gmail.com> - 2013-03-06 08:56 -0800
      Re: Creating an object that can track when its attributes are modified Chris Angelico <rosuav@gmail.com> - 2013-03-07 04:03 +1100
      Re: Creating an object that can track when its attributes are modified 88888 Dihedral <dihedral88888@googlemail.com> - 2013-03-06 13:07 -0800
      Re: Creating an object that can track when its attributes are modified 88888 Dihedral <dihedral88888@googlemail.com> - 2013-03-06 13:07 -0800
    Re: Creating an object that can track when its attributes are modified Ben Sizer <kylotan@gmail.com> - 2013-03-06 08:56 -0800
      Re: Creating an object that can track when its attributes are modified Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-07 00:07 +0000
        Re: Creating an object that can track when its attributes are modified Ben Sizer <kylotan@gmail.com> - 2013-03-06 16:26 -0800
          Re: Creating an object that can track when its attributes are modified Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-08 18:50 +0000
  Re: Creating an object that can track when its attributes are modified Lele Gaifax <lele@metapensiero.it> - 2013-03-06 17:56 +0100
  Re: Creating an object that can track when its attributes are modified Schneider <js@globe.de> - 2013-03-07 13:21 +0100

csiph-web