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.
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
FIXES #81: 400x faster slice assignment #134
FIXES #81: 400x faster slice assignment #134
Changes from 43 commits
f7c3110
6da7389
f02e2d3
b3cf058
f13e159
2f3aee6
017d837
4cd3b72
46677f6
1f8e921
1afb8d4
18f560b
09d37bc
462efc3
68f76a8
9676cea
274d659
45e77c0
4ebd300
ef85351
7e2aec2
e1393bc
62fddc2
98d5a8f
cd18aee
c158171
9084996
aa4a15f
7b3ae95
2c622a9
7a182d6
404ee6b
20c760f
5303605
959691f
fbf1cb7
3780557
42df875
d101a70
7ec6b05
de30021
bab36a9
3b985ee
9c15925
86f4730
a8e0153
5a0bf2b
9573435
86c30d6
a88fb01
89a6a14
25edd03
1640947
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
When I said "works with mypy" better I was referring to the fact that this is listed as
typing.Any
. While I don't dispute "mypy runs without errors" falling back ontyping.Any
defeats the purpose of using type ascription in the first place.This function does not take any type in Python. I think you provided a compelling case for it shouldn't just take
bytearray
, but in that case the list of supported types I think should be listed here undertyping.Union[...]
or something similar.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.
I think it would be good to expand this documentation to explain what happens for the
raise
cases below, for example writing beyond the end of memory. My impression is that it behaves differently than native Python slicing which I think would be good to call out.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.
I think that if
array.array
is to be supported here it needs more work and more tests. Currently there are no tests usingarray.array
and for any size bigger than u8 I don't believe it's correct. For example anarray.array
of 32-bit integers doesn't correctly copy the size of the array into memory. Furthermore endianness is a concern witharray.array
where I don't think that larger than 1-byte values should be supported.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.
you are totally right, should I check for
value.itemsize==1
and throw ValueError or removearray.array
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.
I think this line can be removed?
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.
Is
bytearray
the best choice of conversion here? If the input is abytes
, for example, wouldn't this create a temporary copy before then copying into the linear memory?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.
yes,
bytes
does not work becausesrc_ptr = ptr_type.from_buffer(value)
would giveThere 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.
I don't think that this logic is correct? Here
slice_size
is always equal toval_size
, so thisif
never fires?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.
I don't think that the parentheses around
ptr_type
are necessary here.