Terry Reedy wrote: > "Benjamin Niemann" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > (snip) >>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. > > > According to postings some years ago, the perl folks have worked specially > hard to speed I/O, even to the point of replacing or rewriting some of the > C stdio library, at least for some systems. Hence, at that time, Perl was > expected and known to be noticeably faster than Python on such systems.
The truth is that the Perl version of the "print loop" program is incredibly faster than it's C counterpart (at least on my gentoo/linux box). Since the "no-op loop" program is faster in C (I guess that GCC 'optimizes out' the whole loop !-), it seems clear that Perl's IO do not relie on the stdlib implementation. > Since then, Python I/O has been sped up to at least make better use of > stdio, so the gap may be less. The Python and C versions of the "print loop" program have execution times that are close enough... > 3. One should test computations that are relevant to the question being > asked. Of course !-) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list