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


Groups > comp.lang.python > #66246

Re: A curious bit of code...

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <zachary.ware@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'string': 0.09; 'indeed,': 0.09; '"key': 0.16; 'indexerror:': 0.16; 'subject:bit': 0.16; 'unimportant': 0.16; 'index': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'thu,': 0.19; 'feb': 0.22; 'to:name:python- list@python.org': 0.22; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; '13,': 0.31; 'file': 0.32; 'probably': 0.32; '(most': 0.33; 'received:google.com': 0.35; 'version': 0.36; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'range': 0.61; 'timings': 0.84; 'ware': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=8aQPdIqWzcey5LaHyBeF0qG3D7AS/IMJFIaiDMDcSjk=; b=ij9n4qLIBe48EQlKqpPXdDykqPxXZUuFyFf28XHtV9xjhQOHkkn+cPlrq67PhTsv87 Uc4eoColfPZRGclct2rY16dNqixJxn6Th/+/q8w3R98dOjC2D1frBn3jI5iTf/u1Fbr5 NXoCPWu0GgLQ0SfWQzegLJBVzTM4VPnx4woAlpq0aN3ZNCI3yRswiOmKUyjeHtnMHiHt E5aQNgLP2nslzXMj+XQ3kYY22VjpngrMMhsiGoMZXgwICHQ1B5qRYd2/nPOC2q7Fb7OZ iBGDrqgeHnCVYElpu6YJ6EWwcN+o9tmW9RdjCBHqK1HOFf/cQ7y0Guk4Q11lnWallMID jv6Q==
X-Received by 10.205.6.7 with SMTP id oi7mr89387bkb.62.1392326430049; Thu, 13 Feb 2014 13:20:30 -0800 (PST)
MIME-Version 1.0
Sender zachary.ware@gmail.com
In-Reply-To <ldjbqm$u8n$1@ger.gmane.org>
References <4cc09129-43ee-4205-a24c-03f92b594abc@googlegroups.com> <CAKJDb-OoN2K4--AseaFkuXv3-4vr+a3TPQc7omSrsHVYKcbBrw@mail.gmail.com> <ldjbqm$u8n$1@ger.gmane.org>
From Zachary Ware <zachary.ware+pylist@gmail.com>
Date Thu, 13 Feb 2014 15:20:09 -0600
X-Google-Sender-Auth pjJRPx9I2SHjhV0OBx-CtxM9zkc
Subject Re: A curious bit of code...
To "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.6888.1392326438.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392326438 news.xs4all.nl 2880 [2001:888:2000:d::a6]:54821
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66246

Show key headers only | View raw


On Thu, Feb 13, 2014 at 3:01 PM, Neil Cerutti <neilc@norwich.edu> wrote:
> On 2014-02-13, Zachary Ware <zachary.ware+pylist@gmail.com> wrote:
>> C:\tmp>py -m timeit -s "key = ''" "key[0] == '<' and key[-1] == '>'"
>> Traceback (most recent call last):
>>   File "P:\Python34\lib\timeit.py", line 292, in main
>>     x = t.timeit(number)
>>   File "P:\Python34\lib\timeit.py", line 178, in timeit
>>     timing = self.inner(it, self.timer)
>>   File "<timeit-src>", line 6, in inner
>>     key[0] == '<' and key[-1] == '>'
>> IndexError: string index out of range
>
> The corrected version
>
> key and key[0] == '<' and key[-1] == '>'
>
> probably still wins the Pretty Unimportant Olympics.

Indeed, see the last set of timings and moral ;)

-- 
Zach

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


Thread

A curious bit of code... forman.simon@gmail.com - 2014-02-13 10:37 -0800
  Re: A curious bit of code... Roy Smith <roy@panix.com> - 2014-02-13 13:45 -0500
  Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 10:45 -0800
  Re: A curious bit of code... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-13 19:09 +0000
  Re: A curious bit of code... Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2014-02-13 20:05 +0100
  Re: A curious bit of code... Neil Cerutti <neilc@norwich.edu> - 2014-02-13 19:17 +0000
  Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 11:20 -0800
    Re: A curious bit of code... Roy Smith <roy@panix.com> - 2014-02-13 14:28 -0500
  Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 11:25 -0800
  Re: A curious bit of code... Neil Cerutti <neilc@norwich.edu> - 2014-02-13 19:25 +0000
  Re: A curious bit of code... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-13 19:32 +0000
  Re: A curious bit of code... Peter Otten <__peter__@web.de> - 2014-02-13 20:43 +0100
    Re: A curious bit of code... Marko Rauhamaa <marko@pacujo.net> - 2014-02-13 21:56 +0200
  Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 11:23 -0800
  Re: A curious bit of code... Neil Cerutti <neilc@norwich.edu> - 2014-02-13 19:51 +0000
  Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 11:59 -0800
  Re: A curious bit of code... Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-02-13 13:59 -0600
  Re: A curious bit of code... Chris Angelico <rosuav@gmail.com> - 2014-02-14 07:29 +1100
  Re: A curious bit of code... Tim Chase <python.list@tim.thechases.com> - 2014-02-13 14:39 -0600
  Re: A curious bit of code... Emile van Sebille <emile@fenx.com> - 2014-02-13 12:55 -0800
    Re: A curious bit of code... Roy Smith <roy@panix.com> - 2014-02-13 16:24 -0500
      Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 16:23 -0800
  Re: A curious bit of code... Chris Angelico <rosuav@gmail.com> - 2014-02-14 08:01 +1100
  Re: A curious bit of code... Neil Cerutti <neilc@norwich.edu> - 2014-02-13 21:01 +0000
  Re: A curious bit of code... Peter Otten <__peter__@web.de> - 2014-02-13 22:06 +0100
  Re: A curious bit of code... Chris Angelico <rosuav@gmail.com> - 2014-02-14 08:10 +1100
  Re: A curious bit of code... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-13 21:14 +0000
  Re: A curious bit of code... Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-02-13 15:20 -0600
  Re: A curious bit of code... Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-02-13 15:19 -0600
  Re: A curious bit of code... Emile van Sebille <emile@fenx.com> - 2014-02-13 13:23 -0800
  Re: A curious bit of code... Chris Angelico <rosuav@gmail.com> - 2014-02-14 08:31 +1100
    Re: A curious bit of code... Roy Smith <roy@panix.com> - 2014-02-13 16:38 -0500
  Re: A curious bit of code... Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-02-13 15:47 -0600
  Re: A curious bit of code... Serhiy Storchaka <storchaka@gmail.com> - 2014-02-13 23:49 +0200
    Re: A curious bit of code... Roy Smith <roy@panix.com> - 2014-02-13 16:51 -0500
  Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 13:33 -0800
  Re: A curious bit of code... Chris Angelico <rosuav@gmail.com> - 2014-02-14 09:13 +1100
  Re: A curious bit of code... Ethan Furman <ethan@stoneleaf.us> - 2014-02-13 14:26 -0800
  Re: A curious bit of code... Terry Reedy <tjreedy@udel.edu> - 2014-02-13 19:29 -0500
  Re: A curious bit of code... forman.simon@gmail.com - 2014-02-13 18:45 -0800
    Re: A curious bit of code... Ned Batchelder <ned@nedbatchelder.com> - 2014-02-13 22:26 -0500
      Re: A curious bit of code... forman.simon@gmail.com - 2014-02-14 12:04 -0800
        Re: A curious bit of code... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-14 21:01 +0000
  Re: A curious bit of code... Dave Angel <davea@davea.name> - 2014-02-14 07:19 -0500
    Re: A curious bit of code... Roy Smith <roy@panix.com> - 2014-02-14 09:06 -0500

csiph-web