Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OutStream.writemakesfrozenset(parent.items())for each call. This change keeps the key for the last few parent headers and uses it again when the parent header is the same object. The output does not change.A real kernel (ipc transport) runs these cells. The time is from
executeto the idle status:for i in range(20000): print(i)for i in range(5000): print('x' * 80)a = 1Direct calls to
OutStream.write:write()callsprint(i)callsThe last row is the slow case: each new parent header adds one dict entry. The kernel sets one parent header for each request, so this cost occurs one time for each request.
I used 20 interleaved rounds and a Mann-Whitney test (Apple M5, CPython 3.11). CPython 3.13 and 3.15 gave almost the same numbers. On PyPy 3.11, the write benchmarks are 85-94% faster, and the new-parent case did not change significantly. I did not measure other architectures.
Checks:
pytestgives the same result as onmainon CPython 3.11, 3.14, 3.15 and PyPy 3.11.OutStreamcall sequences and 50,000 random cells in the in-process kernel.