Re: Should I use "if" or "try" (as a matter of speed)?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Should I use "if" or "try" (as a matter of speed)?

From: Edvard Majakari <edvard+news@majakari.net>
Date: Wed Jul 13 2005 - 10:22:37 CEST

Steven D'Aprano <steve@REMOVETHIScyber.com.au> writes:

> My opinion is, no, you don't need to be a C programmer, or an assembly
> programmer, or a hardware level physicist who understands NAND gates, but
> it is very useful to have some understanding of what is going on at the
> low-level implementation.

Yes, I fully agree: in the example presented, it is sufficient to understand
that string concatenation is (relatively) expensive. Yet I'd emphasize that
most often speed is improved by better algorithms, not by low-level
optimisations and language-specific features (if speed is even an issue, that
is).

> The way I see it, programmers need to be somewhat aware of the eventual
> optimization stage in their program, so as to avoid poor design choices
> from the start. But you can't always recognise poor design up front, so
> even more important is careful encapsulation and design, so you
> can make significant implementation changes without needing to throw away
> your work. (Well, that's the theory.)

So true, extra emphasis on encapsulation and independence. Even seasoned
professionals fail to create dazzling products at version 1.0. Good component
design is crucial because you eventually want to do major rewrites later.

-- 
# Edvard Majakari		Software Engineer
# PGP PUBLIC KEY available    	Soli Deo Gloria!
$_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print
join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n";
Received on Thu Sep 29 16:55:26 2005