Repository navigation
Closed
Milestone
Description
When I try to execute this code: https://gist.github.com/kmike/91ef29a3fd2b94ff8b47a5a9ebfa7be2 in an IPython cell (both terminal and notebook), IPython goes to an infinite loop. Code just defines a nested dict; there are unicode symbols. Here is the traceback on interruption:
ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 233, in dispatch_shell
handler(stream, idents, msg)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 208, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 537, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2654, in run_cell
cell = self.input_transformer_manager.transform_cell(raw_cell)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputsplitter.py", line 659, in transform_cell
self.push(cell)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputsplitter.py", line 702, in push
out = self.push_line(line)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputsplitter.py", line 729, in push_line
line = self.assemble_python_lines.push(line)
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputtransformer.py", line 138, in push
for intok in self.tokenizer:
File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/utils/tokenize2.py", line 508, in _tokenize
pseudomatch = pseudoprog.match(line, pos)
KeyboardInterrupt
I have latest ipython[notebook] installed, with all dependencies upgraded as well.
Reacted by Bart Louwers
Metadata
Metadata
Assignees
Labels
No labels
Activity
takluyver commentedon Mar 1, 2018
It's not actually infinite, just very slow. There's some code in current released versions that's O(N^2) on the number of lines in an executed cell. #10898 improves on this, but hasn't been released yet.
Even in master, it takes a while to execute, though. IPython is not a good environment for running very long pieces of code, because we have to go through the code to identify and transform IPython special syntax (
%magicand!systemcommands and so on). We may be able to make that more efficient, but it's probably always going to be slower than putting it in a.pyfile and usingfrom currency_data import CURRENCIES.kmike commentedon Mar 1, 2018
Should I close this ticket as a duplicate?
takluyver commentedon Mar 1, 2018
I'm going to try to find time to look into it some more, because even in master it's unreasonably slow (25 seconds on my computer).
takluyver commentedon Mar 11, 2018
#11041 completely replaces the input transformation machinery, and brings this case up to a reasonable speed. If we go with that, it will probably be fixed in IPython 7.0.
Carreau commentedon Sep 6, 2018
On master that is now fixed, your example is ~quasi instantaneous for me. Closing. Hopping for 7.0 in a few weeks.
kmike commentedon Sep 6, 2018
Awesome, thanks @takluyver and @Carreau!