Some important notes on getting all objects in PythonIt turns out that I'm wrong about several things I mentioned in GetAllObjects, although the code there is still useful and as correct as you can reasonably get. However, it does have a few limitations and may miss objects under some circumstances. First, Second, it's possible that expanding If you need a completely accurate count, you need to use a debug build
of Python. This keeps an internal list of all live dynamically allocated
Python objects and makes it available via some additional functions in
the Even this has an omission: it lists only 'heap' objects, those that
have been dynamically allocated. Python has a certain number of 'static'
objects, such as type objects in the C code (instead of being created,
their names just get registered with the Python interpreter). There
are also static plain objects, for example However, many of these static objects will appear on the expanded
I owe a debt of thanks to Martin v. Löwis, who graciously took the time to correct my misconceptions and errors, and explain things to me. (Any remaining errors are of course my fault.) (The charm of blogging is that I get to make mistakes like this in public. On the upside, I now know a bunch more about the insides of the CPython implementation than I used to.) |
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |