Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'aggressively': 0.16; 'iterator': 0.16; 'message-id:@4ax.com': 0.16; 'range,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'xrange': 0.16; 'sat,': 0.16; 'print': 0.22; 'convenient': 0.24; 'url:home': 0.24; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; 'getting': 0.31; 'closer': 0.31; 'os,': 0.31; 'run': 0.32; 'comment': 0.34; 'test': 0.35; 'but': 0.35; 'ram': 0.36; 'charset :us-ascii': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'rather': 0.38; 'reported': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'times': 0.62; 'console,': 0.84; 'etc,': 0.84; 'worth,': 0.84; 'differences': 0.93; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: print statements and profiling a function slowed performance Date: Sun, 29 Jun 2014 02:14:51 -0400 Organization: IISS Elusive Unicorn References: <5bhtq95qm64rtt8vqbne1ms87t793ab958@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-218-246.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404022505 news.xs4all.nl 2948 [2001:888:2000:d::a6]:52669 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73722 On Sat, 28 Jun 2014 23:50:26 +1000, Chris Angelico declaimed the following: >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. > I chose range() in order to reuse the list (generated outside the timing), rather than include the time of the iterator on both loops. Ran it three times and only had differences in the noise. The main incentive for my "subjective" comment is that I was getting a do-nothing loop that was ~half the time you reported, while the print # loop was ~twice your reported times. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/