Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'lawrence': 0.09; 'measure': 0.09; '10:05': 0.16; 'contest.': 0.16; 'count,': 0.16; 'finish.': 0.16; 'measured': 0.16; 'statement.': 0.16; 'string:': 0.16; 'thread?': 0.16; 'wrote:': 0.18; 'module': 0.19; 'separate': 0.22; 'print': 0.22; 'skip': 0.24; 'logging': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'compared': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'doc': 0.31; 'fri,': 0.33; 'raw': 0.33; 'actual': 0.34; 'created': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'instances': 0.36; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'simple': 0.61; 'delegate': 0.68; 'expectations': 0.74 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 :content-type; bh=u5eb/LkcPXrabFX8F1Oiyxms0ztOnJ0kcaH0j7GNvW4=; b=m4EfzNXf1LMcXLOfGrDO1UjN3/9lEaT7iQTO5eRwr88R2q+nXvJ5icWNkYvdf2lIUM LlMnS609IQtYyMy9qEnUtvKvzbdahhgV1qtp+obDo0wGeXx0GH4hZmqE6+uBi4hR6smE kNZ+zm4IA9zl5DXPwf6KccGbnt8sgPmfUH9sDcN/sou9Hckh5vZzKsWIPTX/hfKYWE7n FKIe7v/MoSGvzeDMmg9tesAr1cWo4lqsiMKSQEORDPp6r8hbEJBn7vppAssk46k9XiTo bmvG8CmB/3C7DOfrX+V+M/88y8gFlXeEpQMy4hkSjiSD+ipI18XMAfBhkVf3270IT2+7 ph2A== X-Received: by 10.67.13.134 with SMTP id ey6mr34223933pad.44.1403904978363; Fri, 27 Jun 2014 14:36:18 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <53acdd24$0$29985$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Fri, 27 Jun 2014 15:35:38 -0600 Subject: Re: print statements and profiling a function slowed performance To: Python 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403904986 news.xs4all.nl 2885 [2001:888:2000:d::a6]:52018 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73674 On Fri, Jun 27, 2014 at 10:05 AM, Skip Montanaro wrote: > On Fri, Jun 27, 2014 at 10:55 AM, Mark Lawrence wrote: >> Expectations don't count, measure it :) > > It's no contest. I have measured it (ages ago). The logging module > does so many things that it's impossible for it to ever be as fast as > a simple print statement. Look at the code in LogRecord.__init__. Then > note the doc string: > > ... LogRecord instances are created every time something is logged. ... While I'm not disputing your measurement, doesn't the logging module delegate the actual I/O to a separate thread? That's got to count for something, compared to a raw print that has to wait for the I/O to finish.