Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; ';-)': 0.03; 'tkinter': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'cheers': 0.12; '"key': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:bit': 0.16; 'tags.': 0.16; 'folks': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'received:comcast.net': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'record': 0.27; "i'm": 0.30; 'code': 0.31; 'markup': 0.31; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'choosing': 0.36; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'email addr:gmail.com': 0.63; 'more': 0.64; 'useful.': 0.68; 'glad': 0.83; '9:45': 0.84; 'flexibility,': 0.84; 'timings': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: A curious bit of code... Date: Thu, 13 Feb 2014 22:26:48 -0500 References: <4cc09129-43ee-4205-a24c-03f92b594abc@googlegroups.com> <839842ff-e0d4-4bec-93fa-b8c25b3ca471@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <839842ff-e0d4-4bec-93fa-b8c25b3ca471@googlegroups.com> 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392348429 news.xs4all.nl 2935 [2001:888:2000:d::a6]:58414 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66278 On 2/13/14 9:45 PM, forman.simon@gmail.com wrote: > For the record I wasn't worried about the performance. ;-) > > It was for Tkinter event strings not markup tags. > > I'm glad this was the time winner! > > "key and key[0] == '<' and key[-1] == '>'" > > > Cheers to the folks who did the timings (and saved me from the trouble!) > > Last but not least... s[::len(s)-1] omg!!? ;-D > If you aren't worried about performance, why are you choosing your code based on which is the fastest? There are other characteristics (clarity, flexibility, robustness, ...) that could be more useful. -- Ned Batchelder, http://nedbatchelder.com