Repository navigation
BUG, ENH: Access PyArrayMultiIterObject fields using macros. - #24658
Conversation
613683d to
6ab7f38
Compare
|
Thanks! Sorry, about testing, this is mainly a Cython problem right now. There are some Cython tests in |
|
It is a bit weird to add new macros in a backport for cython, but I think we need to backport this to allow projects using this (for better or worse) to transition to cython 3. |
|
Could you take another look when you can @seberg. I addressed the above comments and added tests as suggested. |
|
Is your code using these constructs public? I wonder if there is a better way to use the MultiIter than to expose these internals. |
Yes, it is used at several places in this file. An example is this snippet I thought the addition of macros to access information would be considered better than direct access to the struct fields? Also, is there a reason why the Array Iterator API from here is not part of the public API? I would have preferred that over using |
Macros are indeed better than direct access, but even better for flexibility are getter/setter functions, even if they are statically defined. They at least provide some typing information.
I don't think there was ever a demand for it. I am not sure I understand how we "removed |
In #16986 (comment) I mentioned that the ability to access the fields (either directly or indirectly) of a |
|
You can use the new API and we can add it (not backport). I would have guess that hte few times someone wanted it, they added it to their own file because they didn't want to wait for upstream to have it anyway (which doesn't mean you can't add it here, too). |
Skimming through https://numpy.org/doc/stable/reference/c-api/iterator.html, it looks like this would be great as a separate PR so as to not block this one. I am happy to open one that adds the new iterator API to Cython. |
Adds macros to the C-API for accessing `PyArrayMultiIterObject` fields. At the Cython level, these macros can be used to access fields of a `np.broadcast` type.
… build errors on macOS
Could you try again? I think I had to toggle the "Allow edits and access to secrets by maintainers" option |
fc3974b to
1035c5c
Compare
Thanks, worked. |
…#24658) Adds static inline functions to the C-API for accessing `PyArrayMultiIterObject` fields. At the Cython level, these macros can be used to access fields of a `np.broadcast` type.
|
This doesn't backport easily. There are failing tests, the names of have changed (_build) making comparisons difficult. I can probably fix things given time, but it would be easier to forego the backport. EDIT: I'm tempted to tag a commit prior to the change to |
This is a followup to gh-24658, and adds the new Iterator API to the Cython 3.X init.
|
Took this off the backport list. |
Adds macros to the C-API for accessing
PyArrayMultiIterObjectfields. At the Cython level, these macros can be used to access fields of anp.broadcasttype. This is to restore Cython 0.29.X functionality that was lost in #16986 where the fields ofnp.broadcastcould no longer be accessed directly.closes #24649
Cc @seberg, Is there a testing framework for the C-API somewhere? I searched and could not see how one would test the added macros.