Apply normalization consistently in VLenBytes#570
Open
folded wants to merge 4 commits intozarr-developers:mainfrom
Open
Apply normalization consistently in VLenBytes#570folded wants to merge 4 commits intozarr-developers:mainfrom
folded wants to merge 4 commits intozarr-developers:mainfrom
Conversation
None and 0 are treated like a 0 length string when computing lengths, and the same normalization should be applied to the value passed to PyBytes_AS_STRING. If this is not done, an assertion is hit in the python runtime (when compiled in debug mode).
numcodecs/vlen.pyx
Outdated
| data += 4 | ||
| encv = PyBytes_AS_STRING(values[i]) | ||
| b = values[i] | ||
| if b is None or b == 0: # treat these as missing value, normalize |
Member
There was a problem hiding this comment.
Like on line 231? It seems like l = 0 in this case, there is nothing to copy, and these operations are wasted. I might be wrong...
Author
There was a problem hiding this comment.
If you don't pass a bytes object, you will hit this assert when calling PyBytes_AS_STRING: https://github.com/python/cpython/blob/40fff90ae3d46843bb9d27c6a53ef61c861a3bb4/Include/cpython/bytesobject.h#L21
it would be equivalent to skip the PyBytes_AS_STRING and memcpy entirely if l = 0. Shall I update the PR to do that instead?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #570 +/- ##
=======================================
Coverage 99.91% 99.91%
=======================================
Files 59 59
Lines 2334 2334
=======================================
Hits 2332 2332
Misses 2 2 |
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.
None and 0 are treated like a 0 length string when computing lengths, and the same normalization should be applied to the value passed to PyBytes_AS_STRING. If this is not done, an assertion is hit in the python runtime (when compiled in debug mode).
TODO: