[Tutor] Aschenputtel problem - Shorter is not better?

Alan G alan.gauld at freenet.co.uk
Fri Sep 16 09:32:28 CEST 2005


> "Bearing in mind that shorter is not necessarily better..."
>
> Wouldn't shorter, as a rule of thumb, as in less language 
> statements, mean fewer
> executions, and therefore faster?

Only in a very general sense. In practice a complex expression
(such as a list comprehension or a regular expression search)
can expand into a lot of assembler level steps and be bigger
than a multi line but simpler expression.

But even if it were faster, faster is not always better.

If you lose the ability to maintain the code easily or if the complex
single line introduces subtle bugs (like my untested one-liner did!)
then better to be slowly correct than rapidly wrong... :-)

Alan G. 



More information about the Tutor mailing list