Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-11 Thread Ethan Furman
Chris Withers wrote: Sverker Nilsson wrote: The __repr__ I use don't have the enclosing <>, granted, maybe I missed this or it wasn't in the docs in 2005 or I didn't think it was important (still don't) but was that really what the complain was about? No, it was about the fact that when I do

Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-11 Thread Chris Withers
Sverker Nilsson wrote: If you just use heap(), and only want total memory not relative to a reference point, you can just use hpy() directly. So rather than: CASE 1: h=hpy() h.heap().dump(...) #other code, the data internal to h is still around h.heap().dump(...) you'd do: CASE 2: hpy().heap

Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-10 Thread Sverker Nilsson
On Wed, 2009-09-09 at 13:47 +0100, Chris Withers wrote: > Sverker Nilsson wrote: > > As the enclosing class or frame is deallocated, so is its attribute h > > itself. > > Right, but as long as the h hangs around, it hangs on to all the memory > it's used to build its stats, right? This caused me

Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-09 Thread Chris Withers
Sverker Nilsson wrote: But I don't think I would want to risk breaking someone's code just for this when we could just add a new method. I don't think anyone will be relying on StopIteration being raised. If you're worried, do the next release as a 0.10.0 release and explain the backwards inco

Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-08 Thread Sverker Nilsson
On Mon, 2009-09-07 at 16:53 +0100, Chris Withers wrote: > Sverker Nilsson wrote: > > I hope the new loadall method as I wrote about before will resolve this. > > > > def loadall(self,f): > > ''' Generates all objects from an open file f or a file named f''' > > if isinstance(f,basestring):

Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-07 Thread Chris Withers
Sverker Nilsson wrote: I hope the new loadall method as I wrote about before will resolve this. def loadall(self,f): ''' Generates all objects from an open file f or a file named f''' if isinstance(f,basestring): f=open(f) while True: yield self.load(f) It would be

Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-04 Thread Sverker Nilsson
On Fri, 2009-09-04 at 15:25 +0200, Sverker Nilsson wrote: > > However, I am aware of the extra initial overhead to do h=hpy(). I > discussed this in my thesis. "Section 4.7.8 Why not importing Use > directly?" page 36, > > http://guppy-pe.sourceforge.net/heapy-thesis.pdf Actually it is describ

Re: [Guppy-pe-list] An iteration idiom (Was: Re: loading files containing multiple dumps)

2009-09-04 Thread Sverker Nilsson
On Thu, 2009-09-03 at 10:05 +0100, Chris Withers wrote: > Raymond Hettinger wrote: > > In the first case, you would write: > >sets.extend(h.load(f)) > > yes, what I had was: > > for s in iter(h.load(f)): sets.append(s) > > ...which I mistakenly thought was working, but in in fact boils down