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


Groups > comp.lang.python > #10086

Re: Question about timeit

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'removes': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'e.,': 0.16; 'evaluates': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'case.': 0.16; 'maybe': 0.22; "doesn't": 0.22; 'header:In-Reply- To:1': 0.22; 'code.': 0.22; 'parse': 0.23; 'code': 0.24; 'subject:Question': 0.25; 'string': 0.26; 'windows': 0.26; 'guess': 0.28; 'received:84': 0.28; 'call.': 0.29; 'stefan': 0.29; 'second': 0.29; 'float.': 0.30; "skip:' 10": 0.32; 'it.': 0.33; 'actually': 0.33; 'to:addr:python-list': 0.34; 'header:X -Complaints-To:1': 0.34; 'instead': 0.34; 'header:User-Agent:1': 0.34; 'difference': 0.34; 'however,': 0.34; 'but': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'something': 0.38; 'case,': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'plain': 0.40; 'give': 0.60; 'your': 0.60; 'matter': 0.61; 'bottom': 0.62; 'huge': 0.64; 'console,': 0.84; 'schrieb': 0.84; 'what.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Question about timeit
Date Fri, 22 Jul 2011 10:34:01 +0200
References <j0b41p$krj$1@dough.gmane.org> <mailman.1350.1311316646.1164.python-list@python.org> <83238f45-e72d-4ea9-9b4a-a42d26cd7282@x7g2000vbk.googlegroups.com> <j0bb5t$11c$1@r03.glglgl.eu>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-084-056-019-190.pools.arcor-ip.net
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11
In-Reply-To <j0bb5t$11c$1@r03.glglgl.eu>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1353.1311323659.1164.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1311323659 news.xs4all.nl 23862 [2001:888:2000:d::a6]:36852
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10086

Show key headers only | View raw


Thomas Rachel, 22.07.2011 10:08:
> Am 22.07.2011 08:59 schrieb Frank Millman:
>
>> My guess is that it is something to do with the console, but I don't
>> know what. If I get time over the weekend I will try to get to the
>> bottom of it.
>
> I would guess that in the first case, python (resp. timeit.py) gets the
> intended code for execution: int(float('165.0')). I. e., give the string to
> float() and its result to int().
>
> In the second case, however, timeit.py gets the string
> 'int(float("165.0"))' and evaluates it - which is a matter of
> sub-microseconds.
>
> The reason for this is that the Windows "shell" removes the "" in the first
> case, but not the '' in the second case.

Good call. Or maybe it actually gets the code 'int(float(165.0))' in the 
second case, so it doesn't need to parse the string into a float. But given 
the huge difference in the timings, I would second your guess that it just 
evaluates the plain string itself instead of the code.

Stefan

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


Thread

Re: Question about timeit Stefan Behnel <stefan_ml@behnel.de> - 2011-07-22 08:37 +0200
  Re: Question about timeit Frank Millman <frank@chagford.com> - 2011-07-21 23:59 -0700
    Re: Question about timeit Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-07-22 10:08 +0200
      Re: Question about timeit Stefan Behnel <stefan_ml@behnel.de> - 2011-07-22 10:34 +0200
        Re: Question about timeit Frank Millman <frank@chagford.com> - 2011-07-22 05:30 -0700
          Re: Question about timeit Thomas Jollans <t@jollybox.de> - 2011-07-22 14:43 +0200
            Re: Question about timeit Frank Millman <frank@chagford.com> - 2011-07-22 23:30 -0700

csiph-web