Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'compiler': 0.07; 'developer.': 0.07; 'string': 0.09; 'measure': 0.09; 'developer': 0.10; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'increment': 0.16; 'silly': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'command': 0.22; 'code,': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'commands,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'least': 0.26; 'header:In- Reply-To:1': 0.27; 'point': 0.28; 'talent': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; "d'aprano": 0.31; 'fast.': 0.31; 'steven': 0.31; 'says': 0.33; 'worked': 0.33; 'could': 0.34; 'no,': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'c++': 0.36; 'doing': 0.36; 'should': 0.36; 'experience,': 0.37; 'pm,': 0.38; 'short': 0.38; 'sure': 0.39; 'back': 0.62; 'making': 0.63; 'personal': 0.63; 'decided': 0.64; 'mar': 0.68; 'hour': 0.70; 'discover': 0.82; 'faster.': 0.84; 'terrible': 0.84; 'to:none': 0.92; 'average': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=ualZD8d6BYp8svyTQxt03/cbIIq4ZEaVGVjekmXrrgQ=; b=GuambLV5yYUS0MZyFu6UTJw/Tj1RyNl7YY8brmb1Wc8h6/VWbbEfyedMVq4PMvK+w0 Bp/WMNe7OZHUBCiiva/uJ8lWu5jV8Nd3ePVrsTck3Sb2XN2pIm2r3KPZbr5WxkANmdZ/ D8TUn1vhKRxNOpFgXs61H9Xuty4VixrRA49r5db/0CNy2ltwzbANhqJ/7ZR3NhSPS2MJ B1S55uAcMX/3hQjRdwPK4suTkxcrpLzSYfAj/caKZZ1l5RAMpI2WnGJhe89MmTI+guxk XGhOsfLt2X0aWqlXZA0azH+WRwdne1eQAMKGxnLbUJWE4x6BS1B4nwR62deHLxmd4Elb cpKQ== MIME-Version: 1.0 X-Received: by 10.69.25.69 with SMTP id io5mr44530550pbd.22.1394502352844; Mon, 10 Mar 2014 18:45:52 -0700 (PDT) In-Reply-To: <531e6643$0$29994$c3e8da3$5496439d@news.astraweb.com> References: <87eh2d3x8h.fsf_-_@elektro.pacujo.net> <87eh2ctmht.fsf@elektro.pacujo.net> <87zjkz3eo3.fsf@elektro.pacujo.net> <87a9czrrax.fsf@elektro.pacujo.net> <531d3058$0$29994$c3e8da3$5496439d@news.astraweb.com> <87eh2atw6s.fsf@elektro.pacujo.net> <8761nmrnfk.fsf@elektro.pacujo.net> <531e6643$0$29994$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 11 Mar 2014 12:45:52 +1100 Subject: Re: Balanced trees From: Chris Angelico Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394502844 news.xs4all.nl 2908 [2001:888:2000:d::a6]:41949 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68189 On Tue, Mar 11, 2014 at 12:26 PM, Steven D'Aprano wrote: > In my experience, the average developer has an amazing talent for > pessimising code when they think they are optimising it. I remember a number of incidents from personal experience when I was a *very* average developer. One time, writing C++ code, I looked at the disassembly and decided the compiler was doing a terrible job. No no, I could make this so much better by using the 80x86 "REP MOVSW" command (or commands, depending on your point of view). That would be so much better than all those separate operations the silly compiler was doing! Roughly an hour of fiddling later, making sure it all still worked correctly, I discover that... hmm, it's not actually any faster. Turns out the 80x86 string opcodes are really inefficient; they're short (a one-byte command that says "read a byte/word/doubleword from DS:SI, write it to ES:DI, and increment or decrement SI and DI"), but not fast. In my defense, I at least did measure before-and-after, and learned that I should back out that change :) ChrisA