Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73649

Re: print statements and profiling a function slowed performance

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 <rosuav@gmail.com>
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 <d5d8cea5-c4c9-42c4-865f-9efe33b162ed@googlegroups.com> <mailman.11266.1403810884.18130.python-list@python.org> <d1dbc61a-ed09-4a10-b4d5-deb40cb54430@googlegroups.com> <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 <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11276.1403838900.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Fri, Jun 27, 2014 at 12:55 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

print statements and profiling a function slowed performance CM <cmpython@gmail.com> - 2014-06-26 11:44 -0700
  Re: print statements and profiling a function slowed performance Michael Torrie <torriem@gmail.com> - 2014-06-26 13:14 -0600
    Re: print statements and profiling a function slowed performance CM <cmpython@gmail.com> - 2014-06-26 13:36 -0700
      Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-27 12:06 +1000
      Re: print statements and profiling a function slowed performance Michael Torrie <torriem@gmail.com> - 2014-06-26 19:59 -0600
      Re: print statements and profiling a function slowed performance Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-28 09:41 -0400
      Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-28 23:50 +1000
      Re: print statements and profiling a function slowed performance Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-29 02:14 -0400
      Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-29 17:14 +1000
  Re: print statements and profiling a function slowed performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-26 20:27 +0100
    Re: print statements and profiling a function slowed performance CM <cmpython@gmail.com> - 2014-06-26 13:37 -0700
      Re: print statements and profiling a function slowed performance Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-27 02:55 +0000
        Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-27 13:14 +1000
        Re: print statements and profiling a function slowed performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-27 16:55 +0100
        Re: print statements and profiling a function slowed performance Skip Montanaro <skip@pobox.com> - 2014-06-27 11:05 -0500
        Re: print statements and profiling a function slowed performance Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-27 15:35 -0600
        Re: print statements and profiling a function slowed performance Skip Montanaro <skip@pobox.com> - 2014-06-27 19:12 -0500
        Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-28 10:29 +1000
          Re: print statements and profiling a function slowed performance Marko Rauhamaa <marko@pacujo.net> - 2014-06-28 22:20 +0300
            Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-29 09:30 +1000
            Re: print statements and profiling a function slowed performance Rustom Mody <rustompmody@gmail.com> - 2014-06-28 19:25 -0700
              Re: print statements and profiling a function slowed performance Chris Angelico <rosuav@gmail.com> - 2014-06-29 12:32 +1000
        Re: print statements and profiling a function slowed performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-28 02:06 +0100
  Re: print statements and profiling a function slowed performance Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-26 22:11 -0400

csiph-web