Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.048 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'compiler': 0.07; 'developer.': 0.07; 'string': 0.09; 'measure': 0.09; 'developer': 0.10; '7:45': 0.16; 'increment': 0.16; 'silly': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'command': 0.22; 'code,': 0.22; 'separate': 0.22; 'commands,': 0.24; 'mon,': 0.24; '(or': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'point': 0.28; 'chris': 0.29; '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; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'short': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'simply': 0.61; 'back': 0.62; 'making': 0.63; 'personal': 0.63; 'decided': 0.64; 'mar': 0.68; 'hour': 0.70; 'discover': 0.82; 'verification': 0.83; 'faster.': 0.84; 'terrible': 0.84; '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:from:date:message-id:subject:to :content-type; bh=b7bkvaYBpjdPhGbGz3bYtLKddGELTuIqDAV+ULRlJFg=; b=gqXGyL9DS0QiyRl4PQtL4xxAfUpMIwy42H4AXG0+TPEU067rUNffCZ3BwGRkHEPZLW tyJIOxP1CMUevID0DenDpE0C4HygBdjWy5/RDA+ikO0Tvzu7gCoBqUL6GTL9zOGQB1ZN tgj9POItm8DgrgWIq4ZuJdAni6DF+/uMqBf5r0XB+jddjj/o9JkBMszuhyMjohcsF9/6 6dkkxtlTzjaV9DPh5pjddGCXiIAfc0yoFMpYSlNxE5m3JxZv+p4NxhwcsspZ1uD2H7Z0 zl4l36tNqrLMgVIRJUgEDujhls5U+Vf8OGai6Ta9cHjv6emHxMFa+f8KO8Q/vk3N7kaT gnGg== X-Received: by 10.68.170.66 with SMTP id ak2mr44419467pbc.5.1394509123929; Mon, 10 Mar 2014 20:38:43 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: 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> From: Ian Kelly Date: Mon, 10 Mar 2014 21:38:02 -0600 Subject: Re: Balanced trees To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394509126 news.xs4all.nl 2897 [2001:888:2000:d::a6]:44658 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68194 On Mon, Mar 10, 2014 at 7:45 PM, Chris Angelico wrote: > 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 :) Better to have tried and failed though than to have simply accepted what the compiler was doing with no verification at all.