efficient Python object count
darren.ranalli at gmail.com
Fri Nov 7 05:57:37 CET 2008
On Nov 6, 7:28 pm, Christian Heimes <li... at cheimes.de> 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.
Thanks for the quick reply. Could you provide a link to more
information on the debug build you refer to?
More information about the Python-list