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


Groups > comp.lang.python > #83235

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

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 <jonas@wielicki.name>
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 <jonas@wielicki.name>
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 <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>
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 <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.17390.1420459599.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious 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