[pythonvis] Optomization

  • From: "Jim Snowbarger" <snowman@xxxxxxxxxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Sat, 6 Jun 2015 18:01:53 -0500

I hear this now and then, from some of the younger guys on my teadm, quoting
the buzz they have read about so-called premature optimization.

We don't write for a PC. Few people bother with optimization for the PC,
since memory and clock cycles are abundant. But, when you're working in
the kind of world we do, where clock rates are quoted in kilohertz, and
memory is in KBytes, such things are crucial.

AT first, these guys would write for clarity alone, and generally write such
bloated logic that some serious work was require later in order to crunch it
down into something we could actually use. In other words, they basically
had to rewrite it once they understood the problem. And, the prototype, the
first version, mostly served as an exercise to provide that clarity.

Finally, I think I have convinced these guys that there is a big difference
between true premature optimization, and just being reasonable from the get
go, and writing with performance always in the back of your mind.

Once you learn to think in terns of what it is you are actually making the
computer do, you can make coding choices that are not necessarily optimal,
but are significantly better than the bloated prototype you might otherwise
create.

And, if you really do need to optimize it, that will be a much smaller step
now.

What we're finding is that, just by being mindful, and just not doing
profligate things, you can get the bulk of the benefit without compromising
the ease of implementation. It is a nice middle ground.

But, not everything, even in our world, needs to be fully optimized.

You optimize only that which really needs it.

And, you quite simply just be reasonable with everything else.

But, with python, you are pretty far from the machine code that actually
gets generated underneath. Fewer lines does not necessarily equate to less
machine code. I shutter to think what some of it leads to.

But, in the end, I come down to seeking readability, maintainability,
clarity, and simplicity. Clever, is usually trouble in the making.

The best mix between maintainable, and not bloated is where I always strive
to land.



Other related posts:

  • » [pythonvis] Optomization - Jim Snowbarger