New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDLE shell window gets very slow when displaying long lines #42973
Comments
I wrote a little python script that prints a large In fact, the type is irrelevant, what matters is that The shell prints the dictionary into a single line, Even on a high-end PC it takes a minute or even I use Python 2.4.2 on Windows XP SP2. I am aware that it is not exactly wise to print such The average text editor handles such long lines much A quick workaround might be to break very long lines PS: I already observed the bug some years ago. I |
Logged In: YES I verified this with print 100000*'a', also XP (home) sp2. |
Logged In: YES Generally speaking, most wrapping text controls have issues |
Logged In: YES This is a known problem with Tk/Tcl/tkinter - large output I don't see any response problem once the output completes. The What is your use case? IDLE is designed to be an IDE. Why You may be interested in Squeezer, a Noam Raphael extension to http://sourceforge.net/tracker/index.php? I haven't tried it myself, but it might be what you're looking |
Logged In: YES Hi kbk, well, my use case is debugging. I write a script and run it OK, I wait through it, correct the bug, run it again. What Never mind, I can always kill the process... Dammit, I IMHO his takes away one of python's strengths, which is Would you suggest redirecting this issue to tkinter? You I will give squeezer a try. Or maybe PyDev? |
Logged In: YES You can close the window which includes the Shell that has |
Logged In: YES It's not that I don't consider it an issue, but I can't One thing that comes to mind is to set a maximum line Another thing I've wanted to do is provide the ability Yes, you might ask the tkinter guys on their mail list, |
Logged In: YES The Squeezer extension works like a charm! It's also been Why not include it as one of the default extensions, and BTW I have a tweaked version of Squeezer (I fixed the line |
Logged In: YES Sure, please open a patch and supply a diff against |
Logged In: YES Done. |
Logged In: YES Patch 1529353 by Tal Einat |
Patch review in bpo-1529353. |
print(100000*'a') is still a problem in 3.3. |
In addition to squeezing, it would be nice (and easy) to add a menu option (and hotkey) to clear the text pane. |
The only reason that the IDLE shell is slow is due to the shell's text widget being configured to have wrap="char". If we manually wrapped the output then the shell responds very quickly to rendering really long strings. The attached proof-of-concept patch (against 2.7 tip) implements manual wrapping. You can type "print('a' * 10**6)" and the shell responds almost instantly when using no-subprocess mode. (The RPC overhead becomes readily apparent when using a subprocess, introducing a large uninteruptable delay. That's another issue.) I left text wrapping enabled in the shell since the user may be using a variable-spaced font. A possible compromise would be to increase the wrap_index to a large number, like 32768, before IDLE inserts a '\n' into the output. This would mimic the wrapping behavior of the original shell, but keep the shell responsive when you write a very long string to the output. |
manual_wrap.patch patches OutputWindow (2.7) to arbitrarily and blindly wrap at 80 chars. OutputWindow is used directly for grep output, as well as the base for PyShell. The grep output format is currently "'{}: {}: {}'.format(filepath, linenum, codeline)". Output lines are typically (for me) > 80 chars and I would not want a fixed-column wrap. With a right click, one can go to the file and line and this should not be disabled. Ditto for tracebacks, where code lines are pre-wrapped (with an added indent) onto a second physical line. Wrap at 80 would wrap lines that were originally 80 before having the traceback indent added. Autowrap should only be applied to user stdout sent to Shell. Perhaps wrapping should have a window (80-100?) within which we look for a space. I have about concluded that we should add horizontal scrollbars anyway, since Python and IDLE output lines longer than 80 chars. To evaluate the patch further, I want to look at how the socket stream is being read. As long as we are modifying user output before inserting into the text widget, astral chars should be expanded into their unicode escapes. (There are multiple issue for astral chars. Tk 8.7 reportedly will handle them.) The replacement text should be tagged and colored as such. Wrapping should not break replacements. The same could be done for control chars to make them visible. (Astral char handling is needed for paths also!). |
Besides warping text, there has a performance issue inside the RPCServer and Client. The (console, write, (text, file), {}) command is sent by server The result is performed as sent by chunk size, but the client will gather all chunk until it receives all data, then render on IDLE shell. This cause the shell seems like hanging there, and doing nothing (in REPL, it will output the long string to stdout and so on). We can manually detect this then manully chunk out (console, write, args, kwargs) command's args size, so that it will look like not hanging there. The attach patch is a PoC about this. ----- For the text widget performance, I dislike the wrap method, it shouldn't be a limit to the user on IDLE (GUI IDE), even it can be set to 80 or 100 or whatever. |
Squeezer was added last summer, and definitely helps, but I still intend to consider other points raised here. |
This is the oldest performance-labeled bug in the tracker. @terryjreedy Are you still planning to do something about it? |
Squeezer is now integrated into IDLE and enabled by default. That has solved the painfully low responsiveness of IDLE's shell when displaying very long lines of text, which was the original issue raised here, and was a common occurrence. The other points raised here should be considered separate issues IMO:
|
Would you be a dear and create the issue for (2), link it here, and then close this issue? (Or I can close it, if you don't have the powers -- but I don't feel I'm the right person to file the issue, since I haven't thought about or used IDLE in decades.) CC: @terryjreedy |
@gvanrossum, I have the powers, but in all things IDLE I'm deferring to @terryjreedy who has taken the lead on it. This case does seem rather clear-cut though, so I'll go ahead and do as you suggest. |
See issue #96560. |
Thanks, and sorry! I wasn’t sure if you’d made transition to GitHub with us. :) |
No worries :) Unfortunately I've been extremely inactive recently, but hope to change that! |
Here’s to welcome back! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: