[IPython-User] Delayed printing to stdout in the qtconsole
Alejandro Weinstein
alejandro.weinstein@gmail....
Fri Aug 24 14:49:40 CDT 2012
Hi:
If I call a function that take a while to return, say 5 seconds, the
print commands in the qtconsole are delayed. Consider for instance the
following code:
#######################################################
import numpy as np
def slow_f():
'''A function that takes about 4 seconds to run.'''
N = 1200
A = np.random.rand(N, N)
return np.linalg.inv(A)
print 'Calling slow_f for the first time'
B = slow_f()
print 'Calling slow_f for the second time'
C = slow_f()
print 'Calling slow_f for the third time'
D = slow_f()
print 'Done'
#######################################################
If I run this code in a standard IPython console (or just as $python
ip.py), I get (the comments are to indicate the timing):
In [2]: run ip.py
Calling slow_f for the first time # Wait ~4 seconds
Calling slow_f for the second time # Wait ~4 seconds
Calling slow_f for the third time # Wait ~4 seconds
Done
However, if I run the same code in the qtconsole, the output is
In [2]: run ip
# No output for ~4 seconds
Calling slow_f for the first time
Calling slow_f for the second time # These two messages are printed
together, then after 4 seconds
Calling slow_f for the third time # Wait ~4 seconds
Done
Is this different behavior of the qtconsole expected? I'm running the
current master version of IPython (144f08a).
Alejandro.
More information about the IPython-User
mailing list