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


Groups > comp.lang.python > #83203

Re: list comparison vs integer comparison, which is more efficient?

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 <python-python-list@m.gmane.org>
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 <breamoreboy@yahoo.co.uk>
Subject Re: list comparison vs integer comparison, which is more efficient?
Date Sun, 04 Jan 2015 12:30:33 +0000
References <d27586b9-017a-4519-a6bb-e0a1fac005d0@googlegroups.com> <mailman.17365.1420355468.18130.python-list@python.org> <5499f48c-26e3-41c5-8735-2641fde5f35e@googlegroups.com> <7968fa1c-9b4c-4d17-9f71-1bbc55392921@googlegroups.com> <m8bb91$2h7$1@dont-email.me>
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 <m8bb91$2h7$1@dont-email.me>
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.17371.1420374649.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

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


Thread

list comparison vs integer comparison, which is more efficient? austin aigbe <eshikafe@gmail.com> - 2015-01-03 15:19 -0800
  Re: list comparison vs integer comparison, which is more efficient? Chris Angelico <rosuav@gmail.com> - 2015-01-04 10:40 +1100
  Re: list comparison vs integer comparison, which is more efficient? Terry Reedy <tjreedy@udel.edu> - 2015-01-04 02:10 -0500
    Re: list comparison vs integer comparison, which is more efficient? austin aigbe <eshikafe@gmail.com> - 2015-01-04 03:20 -0800
      Re: list comparison vs integer comparison, which is more efficient? austin aigbe <eshikafe@gmail.com> - 2015-01-04 04:17 -0800
        Re: list comparison vs integer comparison, which is more efficient? Christian Gollwitzer <auriocus@gmx.de> - 2015-01-04 13:22 +0100
          Re: list comparison vs integer comparison, which is more efficient? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-04 12:30 +0000
        Re: list comparison vs integer comparison, which is more efficient? Chris Angelico <rosuav@gmail.com> - 2015-01-04 23:25 +1100
        Re: list comparison vs integer comparison, which is more efficient? Jonas Wielicki <jonas@wielicki.name> - 2015-01-04 13:24 +0100

csiph-web