Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'scripts': 0.03; 'interpreter': 0.05; 'output': 0.05; 'debug': 0.07; 'desirable.': 0.07; 'great.': 0.07; 'branching': 0.09; 'debugging.': 0.09; 'executes': 0.09; 'function,': 0.09; 'indeed,': 0.09; 'optimizing': 0.09; 'output,': 0.09; 'python': 0.11; 'useful,': 0.14; 'adjusted': 0.16; 'eliminating': 0.16; 'example)': 0.16; 'fine.': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'print': 0.22; 'subject:problem': 0.24; '---': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'specifically': 0.29; 'generally': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'overhead': 0.31; 'quite': 0.32; 'problem': 0.35; 'subject:with': 0.35; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'instances': 0.36; 'seconds': 0.37; 'application': 0.37; 'too': 0.37; 'received:209': 0.37; 'step': 0.37; 'being': 0.38; 'easiest': 0.38; 'jason': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'duration': 0.60; 'subject:"': 0.60; 'simply': 0.61; 'first': 0.61; 'times': 0.62; 'subject:The': 0.64; 'here': 0.66; 'minutes': 0.67; 'optimized': 0.68; 'business': 0.70; "'dead'": 0.84; 'calls,': 0.84; 'improvement': 0.84; 'upset': 0.84; 'deactivated': 0.91; 'doubling': 0.91; '2013': 0.98 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=RiGvPRdv0edo8AWE5Ic8jSe6DyNRWijF8o4KGkGz940=; b=y3AhBJ8kz2eqRfSZji13pXA1PagxExx4gHojSGdNOo6GxvVOsX50fGM/XKEGF+5zhy 7xfDJ6NQMfy77dUlfjBi478dH50Ze3mHxDpK3xaGf2d6RBK3GQ4XA7zK3oxeaj9qun6e Nv/pGB4xUhDIed1oF7CNHUTmic5TvrV3I26AgwWRWx1D+3chrvYt8XtHs8Pw0GOll+aP jIFZY5TYSjTUEE+Aod87BqB7ACViiha/Kvp7slplDf8zXkVOfAB8zPlcqXyi8njtruvD V4u9tNmo7MR9dEGl4ZZdkRYuK1o9fxU2dLcCLu1OSriR+ffucg57M9vhmXPGO66Fw+// LAUg== X-Received: by 10.66.146.7 with SMTP id sy7mr25645983pab.16.1370279565760; Mon, 03 Jun 2013 10:12:45 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <687dea63-84da-4c45-9366-cb5a10665d1f@googlegroups.com> From: Ian Kelly Date: Mon, 3 Jun 2013 11:12:05 -0600 Subject: Re: PyWart: The problem with "print" To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370279576 news.xs4all.nl 15933 [2001:888:2000:d::a6]:39326 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46800 On Sun, Jun 2, 2013 at 6:16 PM, Jason Swails wrote: > I'm actually with RR in terms of eliminating the overhead involved with > 'dead' function calls, since there are instances when optimizing in Python > is desirable. I actually recently adjusted one of my own scripts to > eliminate branching and improve data layout to achieve a 1000-fold > improvement in efficiency (~45 minutes to 0.42 s. for one example) --- all > in pure Python. The first approach was unacceptable, the second is fine. > For comparison, if I add a 'deactivated' debugprint call into the inner loop > (executed 243K times in this particular test), then the time of the > double-loop step that I optimized takes 0.73 seconds (nearly doubling the > duration of the whole step). It seems to me that your problem here wasn't that the time needed for the deactivated debugprint was too great. Your problem was that a debugprint that executes 243K times in 0.73 seconds is going to generate far too much output to be useful, and it had no business being there in the first place. *Reasonably* placed debugprints are generally not going to be a significant time-sink for the application when disabled. > The easiest way to eliminate these 'dead' calls is to simply comment-out the > print call, but I would be quite upset if the interpreter tried to outsmart > me and do it automagically as RR seems to be suggesting. Indeed, the print function is for general output, not specifically for debugging. If you have the global print deactivation that RR is suggesting, then what you have is no longer a print function, but a misnamed debug function.