Einstein summation notation (was: question of style)

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Jul 17 16:54:53 CEST 2009


On Fri, 17 Jul 2009 07:12:51 -0700, Paul Rubin wrote:

> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
>> def assemble_page(header, body, footer):
>>     if header or body or footer:
>>         do_lots_of_expensive_processing()
>>     else:
>>         do_nothing_gracefully()
> 
> Why should the processing be expensive if all three fields are empty?

Since I haven't specified an implementation for assemble_page, it could 
be doing *anything*. Perhaps it has to talk to a remote database over a 
slow link, perhaps it generates 300 lines of really inefficient HTML code 
with no content, perhaps it sends a print job to a printer which then 
warms up, cleans the print heads, and ejects a blank piece of paper.

Why does it matter? The example is about the `if` test, not about the 
function assemble_page().



-- 
Steven



More information about the Python-list mailing list