What does gc.get_objects() return?

Ian Kelly ian.g.kelly at gmail.com
Wed Mar 12 18:35:13 EDT 2014


On Wed, Mar 12, 2014 at 3:44 PM, Chris Angelico <rosuav at gmail.com> wrote:
> The concept is that the GC tracks (in that sense; everything in
> CPython is refcounted, but that's not what these functions look at)
> anything that could be a part of a reference cycle. That's all it
> concerns itself with, so something that can't have references to
> arbitrary objects can't possibly be worth tracking. Interestingly, a
> tuple of integers is tracked:
>
>>>> a=1,2,3
>>>> gc.is_tracked(a)
> True
>
> So not all optimizations are done that could be done.

Or is it?

>>> a = 1,2,3
>>> gc.is_tracked(a)
True
>>> gc.collect()
0
>>> gc.is_tracked(a)
False



More information about the Python-list mailing list