Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: srinivas devaki Newsgroups: comp.lang.python Subject: Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement? Date: Thu, 12 May 2016 13:53:55 +0530 Lines: 23 Message-ID: References: <20160508183738.2f551043@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de J8JhbAYm52PZxmT4MSA6SQ81tS+KpqMFLoXUFQjrXujQ== 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; 'received:209.85.223': 0.03; 'so?': 0.07; 'subject:skip:c 10': 0.07; 'cc:addr:python- list': 0.09; '[3]:': 0.09; 'to:addr:python.list': 0.09; 'to:addr:tim.thechases.com': 0.09; 'to:name:tim chase': 0.09; 'python': 0.10; 'subject: \n ': 0.15; '2016': 0.16; '[4]:': 0.16; 'quadratic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>': 0.18; 'runs': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; '(you': 0.23; 'header:In- Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'fast.': 0.29; 'loop,': 0.29; 'str': 0.29; "i'm": 0.30; 'point': 0.33; 'usually': 0.33; 'received:google.com': 0.35; 'replaced': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'why': 0.39; 'subject:the': 0.39; 'skip:x 10': 0.40; 'subject:with': 0.40; 'behavior': 0.61; 'per': 0.62; '\xc2\xa0\xc2\xa0': 0.66; 'subject:this': 0.85; 'subject:you': 0.85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CnQplQQUlNlA35gVX/lz+lwtulU/mo3j8msyVJuYVyY=; b=K92SiI91BGACgdn6c3QM6XznO1ULwxi42v+kGDkxIfdYwP7dEd+KDc1IFxzLzjAXfs Zb3tD6Msksl4KRcjhkJAAc5fe8EPtO6nbGPNwFtgeR9NAGX0tCq9PoMQJ5jo4JUzZEbJ AR+lFuVQjE/S8VXF8snTvIqxzQv76N3jNmPwOy5N2QRiMRJWShbTSmtbqZeiDaV4idSY m5WNNjVPRlFTzBiisx69OINBeTM/2C+UPMjD2AGQwotY8Cr+0kpoGnPzOhBiRolTDWfl q3bcPQqwPOD16xwToyRTOA/Dg70QHO4ZGnFLzmibGZwa4uHTh+CkjG+84V/hDhgLwZbs Knfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CnQplQQUlNlA35gVX/lz+lwtulU/mo3j8msyVJuYVyY=; b=MDa3OH7+6ssh44BCUnPVb+TGRtdm1+oib4limNfs0MCBerG/mBpzdIwFNGJMUcusRi t0K7aigSF2Oc/DCTx1MBznIN/HBWLv4NgVusoJ4UiXrs9Yxl3L0gD+hVrWZZq+F7Mxu0 Mqamh/HOWXcadZpzyV5cRo24J9lby8NCSPMd4EV5Ewx5uTd4CS1vnHKXTbZixaCL9K1B WsNyM0iWSUkv+HdskKtRjftasPUkefqLpssi3M0/5EhBDgDcbQtuAg0D1D0pPtSWj09A AeUIipgnqqeJ+AxUq8HsU5nf0gqn5F7e+6ERlmfJSNhdNS4ndRXKeYKeBx/rXXcUfolN Vo1w== X-Gm-Message-State: AOPr4FW0EvRiWED920DKOEaIkzUU0yaXiDI1RMB04UKQPfRObS/RrUKex9Ibli4/5N55ZOJTgvsZXhKC1R7NDg== X-Received: by 10.107.39.138 with SMTP id n132mr7191990ion.103.1463041474434; Thu, 12 May 2016 01:24:34 -0700 (PDT) In-Reply-To: <20160508183738.2f551043@bigbox.christie.dr> X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <20160508183738.2f551043@bigbox.christie.dr> Xref: csiph.com comp.lang.python:108546 On May 9, 2016 5:31 AM, "Tim Chase" wrote: > > then that's a bad code-smell (you get quadratic behavior as the > strings are constantly resized), usually better replaced with > I just want to point out that in Python s += str in loop is not giving quadratic behavior. I don't know why but it runs fast. I'm very much interested to know why it is so? In [3]: %%timeit ...: s = '' ...: for x in xrange(10**6): ...: s += str(x) ...: 1 loop, best of 3: 383 ms per loop In [4]: %%timeit s = '' for x in xrange(10**6): s = s + str(x) ...: 1 loop, best of 3: 383 ms per loop