Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'say,': 0.05; 'cc:addr :python-list': 0.11; 'python': 0.11; '(about': 0.16; 'aggressively': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'range,': 0.16; 'skip:> 20': 0.16; 'xrange': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'cc:addr:python.org': 0.22; 'convenient': 0.24; 'fairly': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'quickly': 0.29; 'message-id:@mail.gmail.com': 0.30; '(maybe': 0.31; 'closer': 0.31; 'comparison': 0.31; 'os,': 0.31; 'run': 0.32; 'fri,': 0.33; 'no,': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'ram': 0.36; 'doing': 0.36; 'seconds': 0.37; 'version,': 0.38; 'pm,': 0.38; 'rather': 0.38; 'simple': 0.61; "you'll": 0.62; 'more': 0.64; 'console,': 0.84; 'etc,': 0.84; 'worth,': 0.84; 'feelings': 0.91; '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; bh=ED7kB2qQhtUZUXNzzyPB8PDZyzISfd+SZYumkoWmzj4=; b=aspI/oEuj3Pe/lSrSHV/CbQHJ7D7LHj2oVqfrLJ7y+zRLu7zEogKKX4CvBRBFGWNIH jZ0whY8CNvk1GF6Sr5Mh6u4LrCLqBE9R9ymfKKHyJnPU4bQoBNotJH6aoSkKykUAi/ow NSmDuHTUQ/jpGPCFC5x09wWiUzzrWCkCyn9v1u+zDXshaUyJmN4RXwFFKcM2zBfxL5Q/ gZ/T6VOuSjzOn5KCQBMtxh1S8+2ODD2uByysP8sV70/Hc7pfbZmACBkWv4dmRq2q6uV6 nVwgNwA0lESeI39WzRcjf9poBMybFcI3PmJK0GboFp+tWWa/nzc/oC+dXNgw0pwVtzvX UVOw== MIME-Version: 1.0 X-Received: by 10.52.248.209 with SMTP id yo17mr2705267vdc.60.1403963426550; Sat, 28 Jun 2014 06:50:26 -0700 (PDT) In-Reply-To: <5bhtq95qm64rtt8vqbne1ms87t793ab958@4ax.com> References: <5bhtq95qm64rtt8vqbne1ms87t793ab958@4ax.com> Date: Sat, 28 Jun 2014 23:50:26 +1000 Subject: Re: print statements and profiling a function slowed performance From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403963435 news.xs4all.nl 2915 [2001:888:2000:d::a6]:56549 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73705 On Sat, Jun 28, 2014 at 11:41 PM, Dennis Lee Bieber wrote: > On Fri, 27 Jun 2014 12:06:54 +1000, Chris Angelico > declaimed the following: > >> >>If x is, say, range(1000000), a simple "for foo in x: pass" will >>complete fairly quickly (maybe 100ms on my computer), while the >>progress-indicated loop will take much longer (about 30 seconds when I >>tried it). Obviously you'll be doing more work than just "pass", but > > I take it those are subjective feelings of time... No, they were measured; but the exact difference will depend on Python version, console, OS, etc, etc, etc, etc, etc, which is why I said "maybe 100ms" - on one run it was about that (rounded aggressively to make for convenient figures), but if I ran the test again, it might come out at 50ms or 200ms. For what it's worth, I did the test on Python 3.5(ish) on Linux; since you tested it on Python 2, a closer comparison would be to use xrange rather than range, to avoid the RAM overhead. ChrisA