Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '(at': 0.03; 'exception': 0.03; 'cpython': 0.05; 'subject:question': 0.08; 'block:': 0.16; 'readable': 0.16; 'subject:coding': 0.16; 'wrote:': 0.17; 'jan': 0.18; '(or': 0.18; 'windows': 0.19; 'supposed': 0.21; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'coding': 0.27; 'execution': 0.27; 'subject:/': 0.28; 'received:209.85.213.174': 0.29; 'received:mail- yx0-f174.google.com': 0.29; 'case,': 0.29; 'function': 0.30; 'doubt': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'continue': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'message-id:@gmail.com': 0.36; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'possible.': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'most': 0.61; 'between': 0.63; 'skip:6 10': 0.63; 'special': 0.73; 'manner': 0.74; 'briefly,': 0.84; 'subject:Basic': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=dMdS0teiXYJY+J+fUk9VbabaXe7MWFEYEpiFEZ8look=; b=uAl0jOg7/DqZrdQt+AbvVJOaYy1h/mmJvIx250naoHuNhiFV1HEZJs3HAGhx8K5y5m SU2edSH5QiFWMmQBDTpnRgu+41uPCKinC17A14aOyeuqJ9Me3SIhkDqBAeHT/+4ICwcD JaGBJWpZ8QFGTXRua8m8KbT1n1jNZS4dIqy7+RDCVu9ZkIMFrYeQde6wNYzWTxrKY4nI QuIbkEGqK1WdwLrED+CivMWmOIwRuhSPR8pqPvnOkYP/ZmI/W5oRUxlF993z8lO2CmQ7 +8n51jVNFXhXzoUDWv196GiI/L0IzBdGMnB5jFDaFF1ZYWK5YW/tSzR9I8NQz4KGBk/H xsyA== Date: Sat, 21 Jul 2012 03:02:29 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: "comp.lang.python" Subject: Re: Basic question about speed/coding style/memory References: <500A5B47.1060805@freenet.de> In-Reply-To: <500A5B47.1060805@freenet.de> X-Enigmail-Version: 1.4.3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 1342857760 news.xs4all.nl 6843 [2001:888:2000:d::a6]:43985 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25726 On 7/21/2012 2:33 AM, Jan Riechers wrote: > Block > ... > versus this block: > ... > Now, very briefly, what is the better way to proceed in terms of > execution speed, readability, coding style? Using if/else is the most readable in the general sense. Using return (or break or continue as applicable) in this manner would indicate (at least to me) that it's an exceptional or otherwise special case and that the function can't do what it's supposed to. In that case, I would try to catch an exception rather than use if/else whenever possible. I highly doubt there is a significant performance difference between them. -- CPython 3.3.0b1 | Windows NT 6.1.7601.17803