Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68292 > unrolled thread

What does gc.get_objects() return?

Started byJurko Gospodnetić <jurko.gospodnetic@pke.hr>
First post2014-03-12 20:34 +0100
Last post2014-03-12 20:34 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  What does gc.get_objects() return? Jurko Gospodnetić <jurko.gospodnetic@pke.hr> - 2014-03-12 20:34 +0100

#68292 — What does gc.get_objects() return?

FromJurko Gospodnetić <jurko.gospodnetic@pke.hr>
Date2014-03-12 20:34 +0100
SubjectWhat does gc.get_objects() return?
Message-ID<mailman.8098.1394652868.18130.python-list@python.org>
   Hi all.

   I was wondering if someone could explain gc.get_objects() in a bit 
more detail to me.

   Does it return a list of 'all objects known to Python'? Only some of 
them? Which does it return? Which it does not?

   For example (done using CPython 3.4 interactive interpreter) here it 
does not contain an object I know exists:

> >>> a = object()
> >>> a in gc.get_objects()
> False

   but here it does:

> >>> class Foo: pass
> ...
> >>> a = Foo()
> >>> a in gc.get_objects()
> True

   It also does not seem to contain string objects. At first I thought 
that perhaps interned strings were not placed under GC control, so I 
tested this:

> >>> a = "asdkjfhk23498237$&(*$&*($ksjdhfkjsd"
> >>> b = "asdkjfhk23498237$&(*$&*($ksjdhfkjsd"
> >>> a is b
> False
> >>> a in gc.get_objects()
> False
> >>> b in gc.get_objects()
> False

   Which shows that non-interned scripts such as these are not getting 
listed in gc.get_objects() either. :-s

   Many thanks.

   Best regards,
     Jurko Gospodnetić

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web