n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.19k stars 185 forks source link

deal with printout overflow #50

Open jacksonloper opened 9 years ago

jacksonloper commented 9 years ago

If I type this...

>> x = new Float32Array(100000);

...I will regret it :). It will try to print out the entire x. If I could successfully interrupt the kernel without losing most of the variables it wouldn't be such a big deal...

I suppose in the long run you'll need some kind of method like chrome has (e.g. here). To implement you'd need need something like jstree which would call back to node to get info tree branches got opened. And of course you'd have to get jstree into jupyter.

... which is all very good stuff for the long term, but I suspect it's not you guys' highest priority :).

In the short term, is there any easy way to truncate printouts on any object which has too many members?

n-riesco commented 9 years ago

I could add a flag, e.g. ijs --ijs-max-output-length=10000. I could do this straight away. How do you think?

There is also the question whether I should set a maximum length by default.

PS: As a workaround until I change this, you could append an additional statement (e.g. 0 or undefined) to prevent IJavascript from printing x out:

> x = new Float32Array(100000); 0;
0
n-riesco commented 9 years ago

Reminder to myself: I need to limit not only the output, but also the TAB and shift-TAB requests.

jacksonloper commented 9 years ago
  1. Simple max-printout flag like that would be great! Could it possibly be set from within the interpreter, perhaps through some global variable?
  2. Another (hopefully quick?) fix would be to write a custom printout function for typed arrays. They are really the most likely thing to be so large that too large to JSON.stringify without crashing the process :). But maybe this should be fixed at the util.inspect level....I'll submit an issue there and see what pops back.
n-riesco commented 9 years ago

Further thoughts:

About the second point you make (use of custom printout functions): this is already in my TODO list. I'm planning to allow users define $$mimer$$, a function that takes an object and returns a custom MIME representation of the object.

n-riesco commented 9 years ago

On 03/11/15 18:23, Jackson Loper wrote:

1.

Simple max-printout flag like that would be great! Could it possibly be set from within the interpreter, perhaps through some global variable?

Unless this is issue is really urgent to you. I want to provide an initial implementation of $$mimer$$ first.

jacksonloper commented 9 years ago

Mimer sounds awesome. Do that.