Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.090 X-Spam-Evidence: '*H*': 0.82; '*S*': 0.00; 'repeated': 0.09; 'wrote': 0.14; 'measurement': 0.16; 'possibly,': 0.16; 'skewed': 0.16; 'subject:which': 0.16; 'load': 0.23; 'header:User-Agent:1': 0.23; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'subject:list': 0.30; 'code': 0.31; 'comparison': 0.31; 'run': 0.32; 'shorter': 0.36; 'subject:?': 0.36; 'should': 0.36; 'list': 0.37; 'easily': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'took': 0.61; 'times': 0.62; 'subject:more': 0.64; 'more': 0.64; 'between': 0.67; 'repeat': 0.74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wielicki.name; s=k001.sol; t=1420374269; bh=NYtAKrDa0xUebib6rK0zzKqGKOz32mveX/NcCsA+3RY=; h=Date:From:To:Subject:References:In-Reply-To; b=Jy0R5CuiP/9eI0KVg/nK7wDcgILdqAhFIxOkJTRDjWW12XelKBwObVsd98QoShaqs TLKy7jCrY/4MSmUBH8xEtemN1tOPBLYdfUacwzxFEyt7IHLQ2Q3jx2u88kIrFBcCpK KmIeCzfOowdDoUPeYLZK/5/TyNffMFqzEj/Zd74eaHpz5gb6d1siMKwFbM620yegFn aWrVqieydiv+z8xMeyoQOqKjtZzFzOxvAqf0W71gOAc71DPepkQ31TJ8Z+9Fuek8Ny RZqLpM8sVnvX0OgHrMiBr5UtusLy0NgR7X1IioJ6yiPRgkjld9j7+tvbpAH6kybGi6 0zuI1BIxnA2HA== Date: Sun, 04 Jan 2015 13:24:26 +0100 From: Jonas Wielicki User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: list comparison vs integer comparison, which is more efficient? References: <5499f48c-26e3-41c5-8735-2641fde5f35e@googlegroups.com> <7968fa1c-9b4c-4d17-9f71-1bbc55392921@googlegroups.com> In-Reply-To: <7968fa1c-9b4c-4d17-9f71-1bbc55392921@googlegroups.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 05 Jan 2015 13:06:38 +0100 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420459599 news.xs4all.nl 2936 [2001:888:2000:d::a6]:33097 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83235 On 04.01.2015 13:17, austin aigbe wrote > Hi Terry, > > No difference between the int and list comparison in terms of the number of calls(24) and time (0.004s). Main part is the repeated call to sqrt(). > > However, it took a shorter time (0.004s) with 24 function calls than your code (0.005s) which took just 13 function calls to execute. How often did you run your measurement? 4ms is not a whole lot and can easily be skewed by sudden system load or other noise. You should call the function more often and/or repeat the measurement several times before coming to a judgement (except, possibly, that it doesn’t matter). cheers, jwi