Re: What does gc.get_objects() return?

2014-03-17 Thread Jurko Gospodnetić
Hi. On 17.3.2014. 18:18, Antoine Pitrou wrote: All in all, though, gc.get_objects() is an expensive function call (it will walk the entire graph of objects tracked by the GC, which can be very large in non-trivial applications), so it's really only useful for debugging (and, I'd ad

Re: What does gc.get_objects() return?

2014-03-17 Thread Antoine Pitrou
e are all implementation details, tied to the fact that the primary object reclaim mechanism in CPython is reference counting. Other implementations may use a full GC and gc.get_objects() may then also return strings and other "atomic" objects (but the implementation may also elicit to ha

Re: What does gc.get_objects() return?

2014-03-13 Thread Jurko Gospodnetić
Hi. On 13.3.2014. 3:54, Terry Reedy wrote: On 3/12/2014 3:34 PM, Jurko Gospodnetić wrote: I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return

Re: What does gc.get_objects() return?

2014-03-13 Thread Jurko Gospodnetić
Hi. On 12.3.2014. 23:40, Ian Kelly wrote: Or is it? a = 1,2,3 gc.is_tracked(a) True gc.collect() 0 gc.is_tracked(a) False Ufff.. nice one :-D Best regards, Jurko Gospodnetić -- https://mail.python.org/mailman/listinfo/python-list

Re: What does gc.get_objects() return?

2014-03-12 Thread Terry Reedy
On 3/12/2014 3:34 PM, Jurko Gospodnetić wrote: I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? This took about

Re: What does gc.get_objects() return?

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 9:35 AM, Ian Kelly wrote: > Or is it? > a = 1,2,3 gc.is_tracked(a) > True gc.collect() > 0 gc.is_tracked(a) > False Huh, *that* is interesting! ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: What does gc.get_objects() return?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 4:35 PM, Ian Kelly wrote: >> So not all optimizations are done that could be done. > > Or is it? > a = 1,2,3 gc.is_tracked(a) > True gc.collect() > 0 gc.is_tracked(a) > False I guess the reason for this is that when PyTuple_New is called, it knows how m

Re: What does gc.get_objects() return?

2014-03-12 Thread Ian Kelly
On Wed, Mar 12, 2014 at 3:44 PM, Chris Angelico wrote: > The concept is that the GC tracks (in that sense; everything in > CPython is refcounted, but that's not what these functions look at) > anything that could be a part of a reference cycle. That's all it > concerns itself with, so something th

Re: What does gc.get_objects() return?

2014-03-12 Thread Chris Angelico
On Thu, Mar 13, 2014 at 8:28 AM, Jurko Gospodnetić wrote: > So gc.collect() returns a list of all the objects GC is in charge of, and > which instances are and are not tracked by the GC is, I guess, an > interpreter implementation detail. I assume you don't mean collect() there, as that returns

Re: What does gc.get_objects() return?

2014-03-12 Thread Jurko Gospodnetić
Hi. On 12.3.2014. 21:02, MRAB wrote: I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? gc.is_tracked(...) might be r

Re: What does gc.get_objects() return?

2014-03-12 Thread MRAB
On 2014-03-12 19:34, Jurko Gospodnetić wrote: Hi all. I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? [snip] gc.

Re: What does gc.get_objects() return?

2014-03-12 Thread Dan Stromberg
On Wed, Mar 12, 2014 at 12:34 PM, Jurko Gospodnetić wrote: > Hi all. > > I was wondering if someone could explain gc.get_objects() in a bit more > detail to me. > > Does it return a list of 'all objects known to Python'? Only some of them? > Which do

What does gc.get_objects() return?

2014-03-12 Thread Jurko Gospodnetić
Hi all. I was wondering if someone could explain gc.get_objects() in a bit more detail to me. Does it return a list of 'all objects known to Python'? Only some of them? Which does it return? Which it does not? For example (done using CPython 3.4 interactive interprete

Re: gc.get_objects()

2012-09-17 Thread Oscar Benjamin
On 2012-09-17, Matteo Boscolo wrote: > from my gc.get_object() > I extract the sub system of the object that I would like to delete: > > this is the object: > Class name > win32com.gen_py.F4503A16-F637-11D2-BD55-00500400405Bx0x1x0.ITDProperty.ITDProperty > that is traked and the reference are: >

Re: gc.get_objects()

2012-09-17 Thread Matteo Boscolo
from my gc.get_object() I extract the sub system of the object that I would like to delete: this is the object: Class name win32com.gen_py.F4503A16-F637-11D2-BD55-00500400405Bx0x1x0.ITDProperty.ITDProperty that is traked and the reference are: get_referents >>>

Re: gc.get_objects()

2012-09-17 Thread Chris Angelico
On Tue, Sep 18, 2012 at 12:16 AM, Steven D'Aprano wrote: > The __del__ method does not delete an object. Remember, objects are only > deleted when there are no references to it. Otherwise you could have some > code that tries to use a deleted object, and you would get a system crash > or BSOD. Th

Re: gc.get_objects()

2012-09-17 Thread Steven D'Aprano
On Mon, 17 Sep 2012 14:42:56 +0200, Matteo Boscolo wrote: > Hi All, > > I'm facing some trouble with a win32com application, it seems, that some > com object (win32com) are still in the gc.get_objetc() list, even if I > set to non the objetc and I'm out of the scope of that objects. You can't se

gc.get_objects()

2012-09-17 Thread Matteo Boscolo
Hi All, I'm facing some trouble with a win32com application, it seems, that some com object (win32com) are still in the gc.get_objetc() list, even if I set to non the objetc and I'm out of the scope of that objects. What I'm try to do is to remove this object from the list. but I do know ho

Re: Memory leak/gc.get_objects()/Improved gc in version 2.5

2007-10-09 Thread arvind
ed that the objects I instantiate are actually > > freed-- I'm therefore assuming that this "leak" is "caused" by > > python's garbage collection mechanism. I count the number of objects I > > generate that are being tracked by gc as foll

Re: Memory leak/gc.get_objects()/Improved gc in version 2.5

2007-10-09 Thread Chris Mellon
trying to determine that is flawed (see below). > 2. I think I've verified that the objects I instantiate are actually > freed-- I'm therefore assuming that this "leak" is "caused" by > python's garbage collection mechanism. I count the number of objec

Re: Memory leak/gc.get_objects()/Improved gc in version 2.5

2007-10-08 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Questions like this about memory consumption should start with the information printed by the interactive interpreter on startup and additional info about whether the binary is from stock CPython or has 3rd party modules compiled in.

Memory leak/gc.get_objects()/Improved gc in version 2.5

2007-10-08 Thread crazy420fingers
hon's garbage collection mechanism. I count the number of objects I generate that are being tracked by gc as follows: gc.collect() objCount = {} objList = gc.get_objects() for obj in objList: if getattr(obj, "__class__", None): name = obj.__class__.

Re: Where are the strings in gc.get_objects?

2007-05-04 Thread Edward K Ream
app.idDict = {} new = {} for obj in gc.get_objects(): oldObj = d.get(id(obj)) if oldObj is None: new[id(obj)] = obj keys = new.keys() print '- %d new objects' % len(keys) if len(keys) < 200: keys.sort() n = 0 for key in keys: n += 1 ...

Where are the strings in gc.get_objects?

2007-05-04 Thread Edward K Ream
for key in keys: n = d.get(key) print '%+6d %s' % (n,key) d = {} ; d2 = {} for obj in gc.get_objects(): t = type(obj) r = repr(t) n = d.get(r,0) d[r] = n + 1 if t == types.InstanceType: t = obj.__class__ r = repr(t) n = d2.