Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'cpython': 0.05; 'interpreter': 0.05; 'instances.': 0.09; 'integers': 0.09; 'cc:addr:python-list': 0.11; 'assume': 0.14; 'at)': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garbage': 0.16; 'listed,': 0.16; 'object()': 0.16; 'tuple': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'not,': 0.20; '>>>': 0.22; '(in': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'possibly': 0.26; 'references': 0.26; 'certain': 0.27; 'values': 0.27; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; '13,': 0.31; 'keys': 0.31; 'with,': 0.31; 'class': 0.32; 'charge': 0.33; 'guess': 0.33; 'raw': 0.33; 'there,': 0.34; "i'd": 0.34; 'could': 0.34; "can't": 0.35; 'something': 0.35; 'beyond': 0.35; 'done.': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'instances': 0.36; 'done': 0.36; 'subject:?': 0.36; 'should': 0.36; 'list': 0.37; 'anything': 0.39; 'itself': 0.39; 'strictly': 0.61; 'such': 0.63; 'worth': 0.66; 'mar': 0.68; 'detail.': 0.68; 'hand': 0.80; '3.4': 0.84; 'atomic': 0.84; 'subject:skip:g 10': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=WHwMPP4EwzBqhhyzNB4EsVWotgv+iG7eYjcggqIUmos=; b=xo/jtnmRsXLDfv58EvrhOSt/jgReApdsfkY2eK0GIEQ1xQ3f5MymKCzvrLAGhUKp1d dUefaItnUuvHugI1eejgJExcT8tchX22Q7NpboC3aWhbC3u28sWOpj30kwI6lwpHX0p7 8M6zXo5gMrrFCpkzjpTt/x3kHqUOHI293Nx4hwLqGnWq1cnEXE+7rApoZHOMApvAjq6v Nue9mGnt3XML/wfjAWRzVXVHkhegyhNgEfsijucVUPjcOWboQCiFy/1OvasxJVFtVJRe sgKC7qFZmsrTGxZmNVyrH0WTdqhgRp3OgzjfBIsKmYNiFf4zIT35b/Y5nI2dyEtliBVC 5XLQ== MIME-Version: 1.0 X-Received: by 10.66.118.71 with SMTP id kk7mr7836502pab.14.1394660696159; Wed, 12 Mar 2014 14:44:56 -0700 (PDT) In-Reply-To: References: <5320BD3F.5030509@mrabarnett.plus.com> Date: Thu, 13 Mar 2014 08:44:56 +1100 Subject: Re: What does gc.get_objects() return? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394660698 news.xs4all.nl 2896 [2001:888:2000:d::a6]:46126 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68300 On Thu, Mar 13, 2014 at 8:28 AM, Jurko Gospodneti=C4=87 wrote: > So gc.collect() returns a list of all the objects GC is in charge of, a= nd > which instances are and are not tracked by the GC is, I guess, an > interpreter implementation detail. I assume you don't mean collect() there, as that returns the amount of garbage that it just collected :) 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 oth= er > 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. Definitely the non-tracking of a dict of nothing but atomic keys and values would be that. 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=3D1,2,3 >>> gc.is_tracked(a) True So not all optimizations are done that could be done. ChrisA