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


Groups > comp.lang.python > #68292

What does gc.get_objects() return?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'scripts': 0.03; 'cpython': 0.05; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'foo()': 0.16; 'object()': 0.16; 'objects.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'all.': 0.16; 'bit': 0.19; 'thanks.': 0.20; '>>>': 0.22; 'example': 0.22; 'header:User- Agent:1': 0.23; 'either.': 0.24; 'skip:" 30': 0.26; 'this:': 0.26; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'wondering': 0.29; 'getting': 0.31; 'them?': 0.31; 'class': 0.32; 'could': 0.34; 'objects': 0.35; 'but': 0.35; 'false': 0.36; 'shows': 0.36; 'subject:?': 0.36; 'detail': 0.37; 'list': 0.37; 'to:addr:python- list': 0.38; 'explain': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'first': 0.61; 'such': 0.63; 'more': 0.64; 'received:46': 0.66; 'here': 0.66; '3.4': 0.84; 'subject:skip:g 10': 0.84; 'charset:windows-1250': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Jurko Gospodnetić <jurko.gospodnetic@pke.hr>
Subject What does gc.get_objects() return?
Date Wed, 12 Mar 2014 20:34:16 +0100
Organization PKE sistemi d.o.o.
Mime-Version 1.0
Content-Type text/plain; charset=windows-1250; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 46.188.175.241
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8098.1394652868.18130.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1394652868 news.xs4all.nl 2939 [2001:888:2000:d::a6]:34381
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68292

Show key headers only | View raw


   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ć

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web