-
-
Notifications
You must be signed in to change notification settings - Fork 764
Minimize copying in maybe_compress & byte_sample
#6273
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
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
8e3d41f
Move `ensure_memoryview` to `distributed.utils`
jakirkham 20b3f9f
Replace `ret` with `mv` for clarity
jakirkham 6fd7179
Coerce `obj` to `memoryview` only if needed
jakirkham 007c8d1
Require `contiguous` data for `.cast("B")`
jakirkham ec4220c
Copy to `bytes` first in non-contiguous case
jakirkham 0a63b8d
Shortcut trivial `memoryview` case
jakirkham 5fa88cf
Fill out docstring & add comments
jakirkham e932c42
Drop unused conversion of `min_size`
jakirkham c3297f7
Join `if` cases together
jakirkham 288bdb4
Use `nbytes` to get `payload` size
jakirkham 7871181
Consolidate payload size checks
jakirkham e8672d3
Use `memoryview` of `payload`
jakirkham d5b9c69
Add tests of `ensure_memoryview`
jakirkham 8a8125d
Test compression with `memoryview`
jakirkham bbed121
Drop blank line & add a comment
jakirkham 2658a4e
Unwrap comment
jakirkham c4299c1
Test empty `bytes` with `memoryview`
jakirkham 6ef14e7
Coerce `b` to `memoryview` to avoid copies
jakirkham e74d3c8
Add blank line
jakirkham f99b523
Special case fewer `parts` in `byte_sample`
jakirkham e4500b9
Shortcut `n == 0` in `byte_sample` sooner
jakirkham 7c801e5
Always return a `memoryview` from `byte_sample`
jakirkham 2a26502
Nest compressibility checks
jakirkham d3064f2
Lighten up on comments around compressibility
jakirkham 2f71f88
Use `;` instead of `,` in comment
jakirkham 17677b8
Use `.nbytes` with `memoryview`s
jakirkham 28d45a3
Clarify `ensure_memoryview` cases in comments
jakirkham 4fd06a1
Also fast path `size == 0`
jakirkham afb1a99
`assert` both `size` & `n` are well behaved
jakirkham fc35a13
Use `islice` with `starts`
jakirkham 689c8a5
From `random` just `import` `randint`
jakirkham a25fb6c
Fast path `not compression` case
jakirkham 72dbad0
Normalize args after size check
jakirkham 3fd096a
Use `mv.nbytes` in compression check
jakirkham 2dab947
Consolidate size check code
jakirkham d02a4e9
Consolidate `size` & `n` handling
jakirkham dcb8c60
Compute largest `start` once
jakirkham 63d94e0
Consolidate fast paths
jakirkham 5d6aa1c
Simplify final comment
jakirkham cf760cc
Fuse loops in `byte_sample` to make `parts`
jakirkham 8612caa
Set `start` to `next_start` at end
jakirkham 883f43f
Tidy comments
jakirkham 8de6296
Tweak wording
jakirkham e4e86bc
Also note `shape` change in comment
jakirkham 57df6fd
Clarify `size` given sample selection behavior
jakirkham 3aded1e
Tweak comment
jakirkham 8aaf04d
Fix comparisons
jakirkham dc04e4c
Shorten docstring in `ensure_memoryview`
jakirkham 75213a4
Preallocate `parts` to match intended size
jakirkham a2d891a
Just use `int`s for `min_size` & `sample_size`
jakirkham 8661564
Call `x.tobytes()` once and assign it
jakirkham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.