loop in python

Benjamin Niemann pink at odahoda.de
Mon Aug 22 17:42:46 EDT 2005


km wrote:

> Hi all,
> 
>> thing.  If *all* your loops are going to do is print stuff, then you're
>> doing the right thing with the version that "emits values".
> 
> ya most of the loops print values.

In that case, you are interested in IO performance. The time spent handling
the loop is not significant compared to the time spent executing the
'print' statement - which is a very complex operation despite its simple
usage.

An implementation where a simple control flow structure has an measurable
impact on the overall timing of an IO bound program would really suprising.
Python suprises me often, but in different ways ;)

Perhaps you could try to use sys.stdout.write() directly, avoiding the
overhead of 'print'. Perhaps there are differences between the (default)
output buffering settings of perl and python.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/



More information about the Python-list mailing list