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! 6 2625
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
On Nov 6, 7:28*pm, Christian Heimes <li...@cheimes.dewrote:
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?
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/b.../GetAllObjects
darrenr wrote:
>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/b.../GetAllObjects
Once I had a strange memory leak in a long running process. This
turned out to be a problem of objects filing up in gc.garbage
("uncollectables").
I think those objects where also not reachable through
gc.get_objects() - as used by the script above. So be aware. Maybe
you've got the same motive for your counter.
I was somewhat stunn seeing, that obviously almost any serious
bigger app needs to watch and handle/free the gc.garbarge list "by
hand", to remain stable.
Robert This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mikko Ohtamaa |
last post by:
Hi,
I am quite new to Python, PythonCom and COM generally. As a former
Java programmer, I have found Python's flexible ability to access
native Win32, especially COM, very comfortable. However,...
|
by: Robert Oschler |
last post by:
Has anybody seen a Python module that will take an XML document (not a
colossal one), and convert it to a Python nested class object? I'm
basically looking for something that would allow me to...
|
by: Alexander Fillips |
last post by:
Hi,
my short question:
is there a python object which can interpret java-script?
the whole story ;-)
I wrote some streaming-scripts for the xbox mediaplayer which supports
python. for a...
|
by: Ara.T.Howard |
last post by:
anyone out there know where i might find a python object model diagram?
cheers.
-a
--
===============================================================================
| email :: ara t ...
|
by: Ron Guerin |
last post by:
The New York Linux User's Group invites you to a special presentation
by Alex Martelli of Google, on the Python Object Model. This
presentation will be held at P.J. Clarke's Sidecar, rather than...
|
by: Ron Guerin |
last post by:
(date and time inadvertently omitted last time. sorry!)
The New York Linux User's Group invites you to a special presentation
by Alex Martelli of Google, on the Python Object Model. This...
|
by: lg2779 |
last post by:
Hello all
I am trying to call the method of python object. But I dont know
how to transfer the pointer of the python object into c++ .
the C++ method to receive python object pointer :
...
|
by: AngelBlaZe |
last post by:
Can you access the c object of a python object directly? Can this be
done in ctypes or directly throught python functions without reverting
to forking the python module?
scanario:
I have pyctx...
|
by: varuns |
last post by:
hi
i m confused in between python object and a c object (which is binded with python code using wrapper function)
when i create a python object and use it to call a c api binded to python
does...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |