add slice-ptr accessors to PyBuffer - #6382
Conversation
Merging this PR will improve performance by 13.23%
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
| /// Returns null if the buffer is not C-style contiguous | ||
| pub fn as_slice_ptr(&self) -> *mut [T] { |
There was a problem hiding this comment.
Would Option<NonNull<[T]>> be better? (And similar on the other methods.)
davidhewitt
left a comment
There was a problem hiding this comment.
Thanks, this looks fine to me now.
I think it might be worth adding some documentation explaining to users that they are responsible for avoiding data races while reading / writing the buffer. We can do that as part of #6381
Add accessors to
PyBufferthat get the data as a pointer to a slice. See #6267