-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add py::array::size() function? #34
Comments
Not sure I agree. Having both an 'itemsize' and 'size' field is highly confusing -- calling it 'count' disambiguates which one is a size in bytes, and which one is the element count. The problem with directly exposing size() is that it's an expensive operation. You have to request a buffer view via |
I would agree if this was a "free standing" library and we were free to select new names, but (imo) numpy compatibility is a very strong feature here. In addition
If that is the case, I agree, but Isn't |
That's a good point -- if it's possible to replicate the behavior of PyArray_SIZE without depending numpy headers, then I'm open to adding a function to pybind11::array. However, this would not work for the bare bones pybind11::buffer interface. |
Regarding the rename, the issue started more ambitious: allow access of each |
The issue I see here is that it's impossible to provide these fast access operations to structural data for non-NumPy plain buffer objects. On the other hand, the bindings of |
I had a bug that seems to be related to this, when calling the |
…med count->size to match NumPy naming (fixes #34)
…med count->size to match NumPy naming (fixes #34)
Currently if I want to access a parameter such as array length, the best method to my knowledge is
size_t size = target.request().count;
There are two problems with this. First, the corresponding python name is
size
, so renamingcount -> size
would be nice.Further, wouldnt It be nice to have access to this as a free function?
size_t size = target.size()
The text was updated successfully, but these errors were encountered: