Repository navigation
perf: convert BGRA pixels to RGB in bounded chunks - #611
Open
Wimpykid1a wants to merge 1 commit into
Open
Wimpykid1a wants to merge 1 commit into
Wimpykid1a wants to merge 1 commit into
Conversation
Owner
|
Tested locally on Linux, and the improvement is real! Thanks @Wimpykid1a. |
BoboTiG
reviewed
Nov 28, 2026
| rgb[2::3] = raw[::4] | ||
| # Slice contiguous bytes instead of strided memoryviews. Copying in | ||
| # chunks keeps the temporary buffers small for large screenshots. | ||
| pixels_per_chunk = 8192 |
Owner
There was a problem hiding this comment.
Sould we create a contant at the top of the file? So that if someone wants to test other values for their local setup, it will be easier. And it should be part of the documentation also.
Owner
|
@jholveck & @halldorfannar how does it sounds to you? |
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.
Refs #522.
ScreenShot.rgbconverts the input to contiguous bytes in 8,192-pixel chunks before taking the channel slices. This bounds the temporary buffers while keeping the packed RGB output available as a writable memoryview.In an isolated Linux/WSL process with CPython 3.10.12, median first-access time for synthetic 3840×2160 data went from 338.94 ms to 77.97 ms. Peak traced Python allocations beyond the output dropped from 16,201 KiB to 65 KiB. These numbers measure pixel conversion.
check.shrun hit the Python 3.10 type target on unrelated files. Ruff format and lint passed. Mypy passed on all 67 source files when targeting Python 3.14.AI assistance disclosure
Codex generated the implementation, test, and release note and ran the reported checks.