Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'cpython': 0.05; 'subject:Python': 0.05; 'behave': 0.07; 'python': 0.08; '25,': 0.12; 'am,': 0.12; '16,': 0.15; 'case.': 0.15; '46,': 0.16; '58,': 0.16; 'url:hg': 0.16; 'cc:addr:python-list': 0.16; 'subject:question': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'slightly': 0.19; 'cheers,': 0.20; 'java': 0.21; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'received:209.85.220': 0.25; '"the': 0.26; 'lists': 0.28; "i'm": 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'array': 0.30; 'kelly': 0.30; 'pattern': 0.30; 'chris': 0.30; 'url:python': 0.35; 'subject:lists': 0.36; 'cc:2**1': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'more': 0.61; 'believe': 0.65; 'url:c': 0.74; '10:43': 0.84; '35,': 0.84; 'certain,': 0.84; 'sender:addr:chris': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=WwpOvR5GNt+8yOld+xBFLGTI4c767naUuGuVdO5hOm8=; b=EnMJDriWhNlLRPKBIPZStyB9nIG8sRrUtMg7fjuO0dZu23wX1/nF6lT1Ho8Ml8fQ8x oPPZkaLk2jntLxpceFtjOw8UNIa78ThUw0TDAMNhOY1MDGB89bbccvZq6HmAKNmyccyE 4LMv+ZSTDQ0EDzZ43dIUwyMEa3GSC4CR5JZiE= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Wed, 15 Feb 2012 11:11:27 -0800 X-Google-Sender-Auth: XUq3m9YFWcZBgX_rOD-GimRp2-I Subject: Re: Complexity question on Python 3 lists From: Chris Rebert To: Ian Kelly Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQm+qXSdkOqovMYhAtcHvjjAqaaKyJcWNvmuONIIX+zQmUSfBLDcaeB0BxHfWMqp3K11aiF/ Cc: python-list@python.org, Franck Ditter X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329333090 news.xs4all.nl 6896 [2001:888:2000:d::a6]:43941 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20465 On Wed, Feb 15, 2012 at 10:43 AM, Ian Kelly wrote: > On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote= : >> Do lists in Python 3 behave like ArrayList in Java (if the capacity >> is full, then the array grows by more than 1 element) ? > > I believe the behavior in CPython is that if the array is full, the > capacity is doubled, but I'm not certain, and that would be an > implementation detail in any case. It's slightly more complex: http://hg.python.org/cpython/file/096b31e0f8ea/Objects/listobject.c "The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, =E2=80=A6" -- list_resize() Cheers, Chris