efficient Python object count
Hello, Does anyone know of an efficient way to get a count of the total number of Python objects in CPython? The best solution I've been able to find is len(gc.get_objects()) which unfortunately has to walk a C linked list *and* creates a list containing all of the objects, when all I need is an object count. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient Python object count
On Nov 6, 7:28 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > darrenr wrote: > > Hello, > > > Does anyone know of an efficient way to get a count of the total > > number of Python objects in CPython? The best solution I've been able > > to find is len(gc.get_objects()) which unfortunately has to walk a C > > linked list *and* creates a list containing all of the objects, when > > all I need is an object count. > > There is no way to get correct numbers with a standard Python compiler. > You have to use a special debug build but that requires debug builds of > all extensions too. > gc.get_object() lists only object that are maintained by gc. Several > types don't use gc, for example str, unicode, int, float, long and more. > > Christian Thanks for the quick reply. Could you provide a link to more information on the debug build you refer to? -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient Python object count
> Thanks for the quick reply. Could you provide a link to more > information on the debug build you refer to? A modified version of this algorithm should do the trick for my purposes, it finds the non-containers that gc ignores. I don't care how long it takes to compute, I just don't want the process to block for long periods of time. http://utcc.utoronto.ca/~cks/space/blog/python/GetAllObjects -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient Python object count
> Here you > are:http://svn.python.org/projects/python/branches/release25-maint/Misc/S... Excellent, thank you. -- http://mail.python.org/mailman/listinfo/python-list
