-
Notifications
You must be signed in to change notification settings - Fork 15
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
[change] Rename the data buffer from data
to _buffer
#136
[change] Rename the data buffer from data
to _buffer
#136
Conversation
All this would really do is hide the I am not opposed to a name change since data is kind of vague, perhaps pointer or ptr. I feel that it is valid for an advanced user to want to take ownership of the ptr from NDArray, although I struggle to think of a good reason to do that. |
Yeah, but we have the Pythonic convention that things with single underscore means "private" and ordinary users should not touch it unless knowing the consequence :D With this name, users will understand that they need to be cautious and do not accidentallyy change the data buffer. Actually it is also used for the buffer of the |
For struct String(
...
):
"""Represents a mutable string."""
# Fields
alias _buffer_type = List[UInt8, hint_trivial_type=True]
var _buffer: Self._buffer_type |
|
For sake of simplicity, it can be named as On the one hand, On the other hand, for C users, a structure pointer points to the memory address where the structure is stored, not the buffer of the structure. One still needs to do That is why I think |
@forFudan Yep, |
8b163e5
into
Mojo-Numerics-and-Algorithms-group:pre-0.4
The data buffer of
NDArray
is anunsafepointer
. We should not expose it to the users. So it is renamed to_buffer
with an underscore.