Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'lawrence': 0.09; 'cc:addr :python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'logging,': 0.16; 'should.': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; "haven't": 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'logging': 0.26; 'header:In-Reply- To:1': 0.27; 'quickly': 0.29; 'compared': 0.30; 'message- id:@mail.gmail.com': 0.30; '-0700,': 0.31; "d'aprano": 0.31; 'overhead': 0.31; 'steven': 0.31; 'fri,': 0.33; 'guess': 0.33; 'actual': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'level': 0.37; 'ends': 0.38; 'pm,': 0.38; 'expect': 0.39; 'itself': 0.39; '26,': 0.68; 'printing,': 0.74; '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=5cTctkaPB2+7ZX6PWAYhuf4LkxkICsccw8i8+nhXz08=; b=dsPSLyHxt6ZEu9FV0JIqEUMtql1f3gSKLuH9iNR/gTqsU3y5LLrci/wyOXAhbBX2ky Tg44B0OHjEzV/6NXmna+YW2asXWCLACjhxOXSn2r4r6JTJHKX4CrJ3W+eUnQvNdRL/Hw k5CCbmpD3pEDYTZHYaSUM8XhqJ2ab070zQzZfBxzwu0lxsgY1vQR1dHoSlWYIa35FZKh 7EOBypBmLjvrdDIjznQs4f37WdFk8fe72o1T0e7dLrYosKCDybgU8b/952sfb9AeL2G3 1zZ5LKjgQY6tdedBIOqtognEyQT6EbL/Qx92nC5Ht321IS4kwH7HXILOfrNqN1icBNEA Y85w== MIME-Version: 1.0 X-Received: by 10.52.24.68 with SMTP id s4mr14610841vdf.37.1403838897630; Thu, 26 Jun 2014 20:14:57 -0700 (PDT) In-Reply-To: <53acdd24$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53acdd24$0$29985$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 27 Jun 2014 13:14:57 +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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403838900 news.xs4all.nl 2957 [2001:888:2000:d::a6]:52424 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73649 On Fri, Jun 27, 2014 at 12:55 PM, Steven D'Aprano wrote: > On Thu, 26 Jun 2014 13:37:41 -0700, CM wrote: > >> On Thursday, June 26, 2014 3:27:48 PM UTC-4, Mark Lawrence wrote: >> >>> 3. use the logging module :) >> >> I've just never got around to it, but I guess I should. Thanks for the >> nudge. > > While using the logging module is recommended for logging, if you expect > that logging will be faster than print, I expect you will be disappointed. I would expect it to be faster than print in the case where it ends up not printing, which means you can make one change to logging level and very quickly eliminate all the output. I haven't measured, but I would expect the overhead of the logging module itself to be small compared to the cost of actual console output. ChrisA