Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.04; 'interpreter': 0.04; 'subject:Python': 0.05; 'python': 0.09; '[1,': 0.09; 'called.': 0.09; 'dict': 0.09; 'garbage': 0.09; 'received:mail-vc0-f174.google.com': 0.09; '*why*': 0.16; '3],': 0.16; '[2,': 0.16; '__del__': 0.16; 'cyclic': 0.16; 'dummy': 0.16; 'entries,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'run.': 0.16; 'still,': 0.16; 'terribly': 0.16; 'wrote:': 0.17; 'load': 0.19; 'module': 0.19; 'putting': 0.20; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; "d'aprano": 0.29; 'giant': 0.29; 'necessary,': 0.29; 'received:209.85.220.174': 0.29; 'steven': 0.29; 'probably': 0.29; 'class': 0.29; 'fri,': 0.30; 'stuff': 0.30; 'gets': 0.32; 'minutes,': 0.33; 'to:addr:python- list': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'but': 0.36; "wasn't": 0.36; 'method': 0.36; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'think': 0.40; 'your': 0.60; 'containing': 0.61; 'first': 0.61; 'leaving': 0.62; 'maximum': 0.63; 'different': 0.63; 'million': 0.72; '2013': 0.84; 'trick,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=khK1Z49eOYM0WyBe3m7/bvJCbIwGQpjGWncc97n+ZfE=; b=XJhc+4HgDM+f8SDCwrv7EfD4NKHdYDAUUX+XzKNywZ82uUg3X3YUYHSPHFEYqkhb08 iig0FC0tGG1QCi6ISTXS1PRiH8EYZVZM8llfyUcw9EM8zrA5kPP9ZF+E+VhZGYpmuoyz QXptzmkaxyai2T6cVK4hdfXYkRoyyGux0nvrp++/aXe0b4Hgc5OV76FSFVAEDwPgeczI tOuGj6NbyKJApXCoS88Q54RgmRSEnJdVWtUtHQm1Emq0E96P7ML2r7Pbj0hFgBhu4DUS INl/EPuaftIGszbOGWK39VXDve3DAEvb1BnARjgaQ4gWqXoQ2f7TG0vuhdPib8PwFNvC BcsQ== MIME-Version: 1.0 X-Received: by 10.221.10.14 with SMTP id oy14mr2760204vcb.34.1362071200039; Thu, 28 Feb 2013 09:06:40 -0800 (PST) In-Reply-To: <512f8aa9$0$30001$c3e8da3$5496439d@news.astraweb.com> References: <512f8aa9$0$30001$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 1 Mar 2013 04:06:39 +1100 Subject: Re: Speeding up Python's exit From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362071209 news.xs4all.nl 6957 [2001:888:2000:d::a6]:47049 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40140 On Fri, Mar 1, 2013 at 3:49 AM, Steven D'Aprano wrote: > I think the reason it took so long was that Python was garbage-collecting > a giant dict with 10 million entries, each one containing a list of the > form [1, [2, 3], 4]. But still, that's terribly slow -- ironically, it > took longer to dispose of the dict (12+ minutes) than it took to create > it in the first place (approx 3 minutes, with a maximum load of 4). Leaving the question of just *why* you have so much in your dict..... but anyway. Is it any different if you create a deliberate reference loop and then stuff it into some module somewhere? That would force it to be kept until interpreter shutdown, and then a cyclic garbage collection after that, which quite probably would be never run. A stupid trick, perhaps, but it might work; I tested it with a dummy class with a __del__ method and it wasn't called. Putting it into some other module may not be necessary, but I don't know what happens with the interactive interpreter and what gets freed up when. ChrisA