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


Groups > comp.lang.python > #57888

Re: how to avoid checking the same condition repeatedly ?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.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.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'compiler': 0.07; 'subject:same': 0.07; 'think,': 0.07; '"if': 0.09; 'agree,': 0.09; 'imply': 0.09; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wielding': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; 'putting': 0.22; "shouldn't": 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; '(maybe': 0.31; 'changed.': 0.31; 'constant': 0.31; 'implied': 0.31; 'minimal': 0.33; 'subject:the': 0.34; "can't": 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'performance': 0.37; 'loss': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'break': 0.61; 'profile': 0.61; "you're": 0.61; 'first': 0.61; 'name': 0.63; 'nobody': 0.68; 'said:': 0.68; 'hoist': 0.93; '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:date:message-id:subject:from:to :content-type; bh=OWy1nisdOTX3Z8pC7KJGhBw5KVvtw4N1c5fD3FXOq8s=; b=WqgxMpJ1xzsKWlwnqXuePtQA8jIcajOfGmnomwt25vBxABbDlw8418cjmf0aD7TogT jBU7l9+2Wo+Gvo6RtrshlHEOmvyUzATFVI1z6UoinoyLTlMg6X2ukb3W2XEEwI2qrsSt qZTWZPDcBwo9lxzOC4/ucggJhzH9VWLBwjRDKr2cpTx24AWaLJUieH6eBA5W1snOU77w N7TUW3lbBG7xFf6TmfIUux/fHbS9ao/bhbf3GSSdvZw2WbzZGZO4Y4BlZbtGFvoDNhny gLfIZW5TYBsME3spGPmgb5R+H63iiRZQoTlWl0KfvY8Bv7aVEOBit8wj0OBvIfYPtHXp ihOw==
MIME-Version 1.0
X-Received by 10.68.180.131 with SMTP id do3mr19609931pbc.34.1383028744140; Mon, 28 Oct 2013 23:39:04 -0700 (PDT)
In-Reply-To <be6e08f4-64a2-4502-a69a-152238dd5bae@googlegroups.com>
References <mailman.1693.1382953842.18130.python-list@python.org> <be6e08f4-64a2-4502-a69a-152238dd5bae@googlegroups.com>
Date Tue, 29 Oct 2013 17:39:04 +1100
Subject Re: how to avoid checking the same condition repeatedly ?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
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 <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.1743.1383028753.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1383028753 news.xs4all.nl 15985 [2001:888:2000:d::a6]:39635
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57888

Show key headers only | View raw


On Tue, Oct 29, 2013 at 5:14 PM, Peter Cacioppi
<peter.cacioppi@gmail.com> wrote:
> Nobody (yes, his name is Nobody) said:
>
> "If you're sufficiently concerned about performance that you're willing to
> trade clarity for it, you shouldn't be using Python in the first place."
>
> I don't think it's correct to imply that people very concerned about performance should not use Python. (And I agree, Nobody implied that ;)

No, I don't think he implied that. You can care about performance
while still putting code clarity as a higher priority :) If you
actually profile and find that something-or-other is a bottleneck,
chances are you can break it out into a function with minimal loss of
clarity, and then reimplement that function in C (maybe wielding
Cython for the main work). That doesn't compromise clarity.
Duplicating a loop to hoist a condition _does_. Of course, in C, you
can let the compiler do it for you, but Python can't be sure that it's
as constant as you think, so it can't be changed.

ChrisA

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


Thread

how to avoid checking the same condition repeatedly ? Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-10-28 09:50 +0000
  Re: how to avoid checking the same condition repeatedly ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-28 11:14 +0000
    Re: how to avoid checking the same condition repeatedly ? Chris Angelico <rosuav@gmail.com> - 2013-10-28 22:18 +1100
      Re: how to avoid checking the same condition repeatedly ? Steven D'Aprano <steve@pearwood.info> - 2013-10-29 04:51 +0000
  Re: how to avoid checking the same condition repeatedly ? Piet van Oostrum <piet@vanoostrum.org> - 2013-10-28 14:31 -0400
  Re: how to avoid checking the same condition repeatedly ? Nobody <nobody@nowhere.com> - 2013-10-28 19:37 +0000
    Re: how to avoid checking the same condition repeatedly ? Neil Cerutti <neilc@norwich.edu> - 2013-10-29 13:44 +0000
      Re: how to avoid checking the same condition repeatedly ? rusi <rustompmody@gmail.com> - 2013-10-29 09:13 -0700
  Re: how to avoid checking the same condition repeatedly ? Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-28 23:14 -0700
    Re: how to avoid checking the same condition repeatedly ? Chris Angelico <rosuav@gmail.com> - 2013-10-29 17:39 +1100
  Re: how to avoid checking the same condition repeatedly ? Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-28 23:53 -0700
    Re: how to avoid checking the same condition repeatedly ? Chris Angelico <rosuav@gmail.com> - 2013-10-29 18:09 +1100
  Re: how to avoid checking the same condition repeatedly ? Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-29 16:55 -0700
  Re: how to avoid checking the same condition repeatedly ? alex23 <wuwei23@gmail.com> - 2013-10-30 11:38 +1000
  Re: how to avoid checking the same condition repeatedly ? Mariano Anaya <marianoanaya@gmail.com> - 2013-10-30 06:34 -0700

csiph-web