print time comparison: IDLE versus terminal on ultra 20

S

sam

hi all,

i continue to footle around on my spanking new ultra 20 (1.8GHz /
Opteron Model 144), gradually trying to get to grips with python and
unix both.

the slow print time in IDLE had already struck me as rather odd.
running programs with heavy print requirements from the terminal was a
major discovery though, printing being so fast as to make everything
appear at once except in the case of literally thousands of items to be
printed.

test case:

import time

time1 = time.time()
for i in range(100):
print 'go get \'em, son!'
time2 = time.time()

print time2-time1


in IDLE:
4.433 seconds

in terminal:
0.001 seconds

a difference of between 3 and 4 orders of magnitude is rather striking.
anyone know what's going on here? is it a python, a unix thing, or
something else?

sam
 
F

Fredrik Lundh

sam said:
in IDLE:
4.433 seconds

IDLE is designed for tinkering, not fast handling of non-trivial amounts
of output (it runs your program in a separate process and pipes data
to the interactive window over the network. and the interactive seems
to be redrawing the display for every line that arrives...)

but on the other hand, IDLE runs your sample script in less than 0.5
seconds on my cheap Windows box. complain to Sun ;-)

</F>
 
S

sam

i was actually experimenting on windows on my own pc before the
workstation arrived, and IDLE printed a lot faster on windows than in
solaris for me too.

i would indeed complain to sun if i had ever got the impression that
anyone over there ever knew what was going on... : )
 
M

MrJean1

On my Ultra 20 box, the test program takes 0.00039982 secs in a
terminal window and 0.236839 secs in IDLE, i.e. about 600x slower.
This is ActivePython 2.4.3 for Solaris 10 on a 2+ GHz Opteron.

A partial explanation for the difference in run time between terminal
and IDLE is that IDLE uses thru a Tkinter/Tcl/Tk window which
postprocesses the output, like colorizing, etc.

/Jean Brouwers

PS) On MacOS X 10.3.9 and a 400 MHz G4 the terminal time is 0.172556
secs and IDLE takes between 4.04731 and 4.87804 secs (depending on the
options selected) or 24-28x longer . This is Python 2.4.3, IDLE 1.1.3
and Tcl/Tk 8.4.13 as distributed with MacOS X.
 
S

sam

i forgot to mention that i'm running a version of python 2.3 (think
it's 2.3.5), as that's what was installed and i'm not hooked up to the
internet with the ultra 20 yet. that may account for some of the
difference.

sam
 
M

MrJean1

With the binaries /usr/sfw/bin/python and /usr/sfw/bin/idle the results
are 0.002279 resp. 0.222831 secs for the same print test.

The Python version is 2.3.3 and IDLE version 1.0.2 on the same Ultra 20
Opteron box running Solaris 10.

/Jean Brouwers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top