Getters and Setters
Markus Stenberg
mstenber at cc.Helsinki.FI
Sun Jul 18 15:42:34 EDT 1999
More information about the Python-list mailing list
Sun Jul 18 15:42:34 EDT 1999
- Previous message (by thread): Getters and Setters
- Next message (by thread): Getters and Setters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
tim_one at email.msn.com writes: > [Bernhard Herzog <herzog at online.de] > > The cycle doesn't involve self, but self's dict will hold an > > indirect reference to itself. The instance object will be > > deleted, so it's __del__ method is called, but its __dict__ > > won't be deleted: > > Ah -- got it. Thanks for the explanation. self.__del__ is called, > though, so the cycles are easy to break: > > def __del__(self): > self.__dict__.clear() That's only painful if other classes define __del__ too while using this as mixin.. (lazily yours ;>) > even-tested-it-this-time<wink>-ly y'rs - tim Just to contrib something to the discussion.. (note that test period wasn't extensive, but I doubt it'd vary much) normal get : 127539.1651/sec [0.24s] (7.8407us/call) (foo.x) normal set : 101784.9252/sec [0.29s] (9.8246us/call) (foo.x=0) normal getattr: 118375.8787/sec [0.25s] (8.4477us/call) (getattr(foo,'x')) normal setattr: 110274.2723/sec [0.27s] (9.0683us/call) (setattr(foo,'x',1)) FastGet : 75519.0025/sec [0.40s] (13.242us/call) (instance method wrapper) FastSet : 64276.5807/sec [0.47s] (15.558us/call) SlowGet : 43534.9160/sec [0.69s] (22.970us/call) (class method wrapper) SlowSet : 38138.5309/sec [0.79s] (26.220us/call) Obviously, the first call is slow, but beyond that, it seems reasonable enough - I might even use it, one of these days, in my programs ;-) -Markus -- "If you want to travel around the world and be invited to speak at a lot of different places, just write a Unix operating system." -- Linus Torvalds
- Previous message (by thread): Getters and Setters
- Next message (by thread): Getters and Setters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list