Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.107 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.79; '*S*': 0.00; 'say,': 0.05; 'alain': 0.09; 'creates': 0.14; '1),': 0.16; 'calculates': 0.16; 'chunks.': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'updating': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'bigger': 0.30; 'code': 0.31; 'object.': 0.31; 'anyone': 0.31; 'lists': 0.32; 'probably': 0.32; 'subject:the': 0.34; 'but': 0.35; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'new': 0.61; "you'll": 0.62; 'size.': 0.65; 'charset:windows-1252': 0.65; 'received:74.208': 0.68; 'confusing': 0.84; 'overall,': 0.84; 'received:74.208.4.194': 0.84; 'ref': 0.84 Date: Wed, 06 May 2015 16:23:08 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Throw the cat among the pigeons References: <87h9rvm576.fsf@Equus.decebal.nl> <55499304$0$12978$c3e8da3$5496439d@news.astraweb.com> <5549b41f$0$12927$c3e8da3$5496439d@news.astraweb.com> <8761853fkd.fsf@jester.gateway.sonic.net> <87pp6doh09.fsf@universite-de-strasbourg.fr.invalid> In-Reply-To: <87pp6doh09.fsf@universite-de-strasbourg.fr.invalid> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:eAD5YAOT2kgNI8UN09HhxUYWVoqcWFgjKZOvYxVMrdMY31Zrrxe yNVjLiQCZ89IkF2TnQJ9r1l+VeRpmvtRPxqujSlemuP+6aXVjCV3+RLbQR2IG/b0DPUIBGn CMHwIiIjHWJdwwicOMqDAyjZ5FjftGMrpieiLEiQLorbnSH0her+fdEHEUztsx/syuP5Rfb U0sKYnV1jaOY5eowlZ3Bg== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430943800 news.xs4all.nl 2932 [2001:888:2000:d::a6]:46882 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90071 On 05/06/2015 11:36 AM, Alain Ketterlin wrote: > Yes, plus the time for memory allocation. Since the code uses "r *= > ...", space is reallocated when the result doesn't fit. The new size is > probably proportional to the current (insufficient) size. This means > that overall, you'll need fewer reallocations, because allocations are > made in bigger chunks. That sounds plausible, but a=5; a*=4 does not update in place. It calculates and creates a new object. Updating lists can work as you say, but an int is immutable. It's an optimization that might be applied if the code generator were a lot smarter, (and if the ref count is exactly 1), but it would then be confusing to anyone who used id(). -- DaveA