Best search algorithm to find condition within a range
rosuav at gmail.com
Thu Apr 9 17:34:17 CEST 2015
On Fri, Apr 10, 2015 at 1:11 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Thu, 9 Apr 2015 11:33 pm, Marko Rauhamaa wrote:
>> In this day and age, heavily optimized compilers (including gcc)
>> actively exploit undefined behavior in code generation.
> Optimization and undefined behaviour reminds me of a story my wife told me,
> of a time she was crossing the US with some roadies. As they were driving
> across the desert highway, one of the roadies noticed that they were
> driving in the wrong direction for their next gig.
> "Who cares?" said the driver, "we're making fantastic time!"
It's not really like that. Imagine you're loading up the stuff on the
back of your truck. Do you have to research the narrowest tunnel
you'll ever have to go through? Nah. You just make sure it's no wider
than the legal limit, because any tunnel that's narrower than that
isn't your problem. If you ever _do_ meet an overly-narrow tunnel,
you'll run into problems, because you assumed that such a thing wasn't
The C compiler is generally going to assume a whole slew of principles
that aren't technically guaranteed. For instance, it'll probably
assume that CPU registers will accurately retain what they were set
to, and likewise memory (unless it's marked 'volatile'). Put your code
out in space, and that might no longer be true, but you can't expect
the compiler to cope with that. As far as it's concerned, it's
impossible for a CPU register to arbitrarily change without notice.
It's equally impossible for the addition of two positive signed
integers to result in a negative integer.
More information about the Python-list