-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Fix performance of streaming long text #14941
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a performance issue when streaming long text output by changing the internal data structure from string concatenation to list accumulation. The change addresses issue #14937 where streaming large amounts of text was inefficient due to repeated string reallocation.
Key changes:
- Replaces string concatenation with list accumulation for stream data
- Updates type annotations to reflect the new data structure
- Adds a performance test to verify the fix
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/test_interactiveshell.py | Adds performance test for streaming operations |
IPython/core/magics/basic.py | Updates notebook output handling to work with list-based stream data |
IPython/core/interactiveshell.py | Changes stream data accumulation from string concatenation to list appending |
IPython/core/history.py | Updates type annotation for bundle to support both string and list types |
Comments suppressed due to low confidence (1)
tests/test_interactiveshell.py:95
- The performance test only verifies that execution completes within 10 seconds but doesn't validate that the output is correct. Consider adding an assertion to verify that the expected output (numbers 0-249999) is actually produced.
assert duration < 10
This looks good! Thanks 🙌 |
Fixes #14937
CC @Darshan808