Note that all experiments have been performed on Python3.4.3 and IPython 5.1.0 (for python3).
Consider a function that returns the identity:
def my_func():
return 1
Now, this function is called from a loop inside a REPL session.
for _ in range(3):
my_func()
On, IPython, nothing is displayed.
In [96]: for _ in range(3):
...: my_func()
...:
In [97]:
But, on the REPL, something is:
>>> for _ in range(3):
... my_func()
...
1
1
1
>>>
Why is there a difference?
Is it because of something IPython does? I've examined the bytecode and in either case, they're identical. So, it has nothing to do with the bytecode generation but rather with how it is interpreted in either case.