Skip to content

API: Expose PyArray_Pack#25954

Merged
charris merged 1 commit intonumpy:mainfrom
seberg:pyarray-pack
Mar 7, 2024
Merged

API: Expose PyArray_Pack#25954
charris merged 1 commit intonumpy:mainfrom
seberg:pyarray-pack

Conversation

@seberg
Copy link
Member

@seberg seberg commented Mar 7, 2024

Fixes #23893

This is a very simple PR to finally expose this function. I was thinking to change things to const where possible but, don't want the noise here and really the const qualifiers here could be added at any point.

*/
NPY_NO_EXPORT int
PyArray_Pack(PyArray_Descr *descr, char *item, PyObject *value)
PyArray_Pack(PyArray_Descr *descr, void *item, PyObject *value)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a bit of a habit of using char since we do pointer arithmetic with strides so much. But I think here void * is the normal thing clearly.

Copy link
Member

@ngoldbaum ngoldbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebasing should fix the polynomial printing tests

@mattip
Copy link
Member

mattip commented Mar 7, 2024

Do you see an immediate need for this in a particular library, or a specific library where it could replace PyArray_SETITEM? I wonder if this will find much use.

@seberg
Copy link
Member Author

seberg commented Mar 7, 2024

I see PyArray_SETITEM as an ani-pattern almost, because it isn't the same as arr1d[0] value and also because it requires an array object. I suspect a lot of places (if there are many, sure) where SETITEM is used should use it instead, so I like the idea of introducing it for future users, @ngoldbaum also wanted it at some point for the user-dtypes (This closes gh-23893).

@charris
Copy link
Member

charris commented Mar 7, 2024

close/reopen

@charris charris closed this Mar 7, 2024
@charris charris reopened this Mar 7, 2024
@charris charris merged commit 2fe6009 into numpy:main Mar 7, 2024
@charris
Copy link
Member

charris commented Mar 7, 2024

Thanks Sebastian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAINT: Expose PyArray_Pack and deal with PyArray_SETITEM

4 participants