Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'cpython': 0.05; 'debugging': 0.07; 'instances.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:()': 0.09; '(and,': 0.16; '(it': 0.16; 'add,': 0.16; 'from:addr:pitrou.net': 0.16; 'from:addr:solipsis': 0.16; 'from:name:antoine pitrou': 0.16; 'listed,': 0.16; 'message-id:@post.gmane.org': 0.16; 'non- trivial': 0.16; 'object()': 0.16; 'received:213.41.240': 0.16; 'received:213.41.240.54': 0.16; 'received:80.91.229.3': 0.16; 'received:charlus.yi.org': 0.16; 'received:plane.gmane.org': 0.16; 'received:yi.org': 0.16; 'all,': 0.19; '(but': 0.19; 'mechanism': 0.19; 'not,': 0.20; 'hack': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'closely': 0.24; 'primary': 0.26; 'certain': 0.27; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'writes:': 0.31; 'class': 0.32; 'guess': 0.33; 'raw': 0.33; "i'd": 0.34; 'tool': 0.35; 'beyond': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'instances': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'should': 0.36; 'wrong': 0.37; 'to:addr:python-list': 0.38; 'fact': 0.38; 'expensive': 0.39; 'though,': 0.39; 'use.': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'full': 0.61; 'entire': 0.61; 'strictly': 0.61; 'such': 0.63; 'details,': 0.68; 'subjectcharset:utf-8': 0.72; 'walk': 0.74; 'hand': 0.80; '3.4': 0.84; 'antoine.': 0.84; 'atomic': 0.84; 'situations,': 0.84; 'subject:skip:g 10': 0.84; 'tied': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Antoine Pitrou Subject: Re: What does =?utf-8?b?Z2MuZ2V0X29iamVjdHMoKQ==?= return? Date: Mon, 17 Mar 2014 17:18:05 +0000 (UTC) References: <5320BD3F.5030509@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 213.41.240.54 (Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395076808 news.xs4all.nl 2910 [2001:888:2000:d::a6]:41989 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68439 Chris Angelico 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.