Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.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.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language.': 0.14; 'times,': 0.14; 'loop.': 0.16; 'operates': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:which': 0.16; 'language': 0.16; 'wrote:': 0.18; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'second': 0.26; 'least': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'subject:list': 0.30; 'code': 0.31; 'run': 0.32; 'url:python': 0.33; 'maybe': 0.34; 'tool': 0.35; 'shorter': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'too': 0.37; 'christian': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'results.': 0.60; 'url:3': 0.61; 'took': 0.61; 'times': 0.62; 'information': 0.63; 'such': 0.63; 'our': 0.64; 'subject:more': 0.64; 'charset:windows-1252': 0.65; '20000': 0.84; 'benchmark': 0.84; 'timing.': 0.84; 'typically,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: list comparison vs integer comparison, which is more efficient? Date: Sun, 04 Jan 2015 12:30:33 +0000 References: <5499f48c-26e3-41c5-8735-2641fde5f35e@googlegroups.com> <7968fa1c-9b4c-4d17-9f71-1bbc55392921@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-24-222-48.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420374649 news.xs4all.nl 2931 [2001:888:2000:d::a6]:55507 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83203 On 04/01/2015 12:22, Christian Gollwitzer wrote: > Am 04.01.15 um 13:17 schrieb austin aigbe: >> 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. > >> Why is this? > > These times are way too short for conclusive results. Typically, the OS > timer operates with a millisecond resolution. You need to run a > benchmark at least for a second to get reliable information about > timing. INstead of 24 times, call your function 20000 times in loop. > > Christian > Maybe using a custom built tool such as https://docs.python.org/3/library/timeit.html#module-timeit ? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence