Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68439 > unrolled thread
| Started by | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| First post | 2014-03-17 17:18 +0000 |
| Last post | 2014-03-17 17:18 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: What does gc.get_objects() return? Antoine Pitrou <solipsis@pitrou.net> - 2014-03-17 17:18 +0000
| From | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| Date | 2014-03-17 17:18 +0000 |
| Subject | Re: What does gc.get_objects() return? |
| Message-ID | <mailman.8206.1395076808.18130.python-list@python.org> |
Chris Angelico <rosuav <at> gmail.com> writes: > > It's not strictly an implementation detail, beyond that there are > certain optimizations. For instance... > > > For CPython 3.4 I guess strings and other atomic types such as ints are > > not, as well as raw object() instances. Custom class instances on the other > > hand seem to be under GC control. > > ... strings and ints should never be listed, and custom objects should > always be listed, but I'd say the non-tracking of object() would be an > implementation-specific optimization. These 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 hack get_objects() in order to closely mimick CPython). 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 add, for low-level debugging). In most situations, gc.get_objects() is certainly the wrong tool to use. Regards Antoine.
Back to top | Article view | comp.lang.python
csiph-web