Skip to content
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

Use Cython's array to back Py_ssize_t[::1] #1087

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

jakirkham
Copy link
Member

In Array, Py_ssize_t[::1] objects are currently backed by CPython array's with some internal bits expressed in Cython. However these are not compatible with Python's Limited API and Stable ABI. To address that, switch to Cython's own array type. As this is baked into Cython and doesn't use anything special, it is compatible with Python's Limited API and Stable ABI.

xref: rapidsai/build-planning#42

In `Array`, `Py_ssize_t[::1]` objects are currently backed by CPython
`array`'s with some internal bits expressed in Cython. However these are
not compatible with Python's Limited API and Stable ABI. To address
that, switch to Cython's own`array` type. As this is baked into Cython
and doesn't use anything special, it is compatible with Python's Limited
API and Stable ABI.

https://cython.readthedocs.io/en/latest/src/userguide/memoryviews.html#cython-arrays
@jakirkham
Copy link
Member Author

Did a simple benchmark in this comment: rapidsai/kvikio#504 (comment)

Basically this is a bit slower, but no more than the time of 1-2 attribute accesses on an object

@pentschev
Copy link
Member

I tried to do some benchmark with UCX-Py but the variability prevents us from reaching any conclusive results regarding performance before and after this change, where sometimes results are better before and other times after, therefore I think it doesn't impose any negative impact that would be noticeable in practical use cases.

Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @jakirkham .

@pentschev
Copy link
Member

/merge

@rapids-bot rapids-bot bot merged commit a3aedc7 into rapidsai:branch-0.41 Oct 22, 2024
39 checks passed
@jakirkham jakirkham deleted the use_cvarray_arr branch October 22, 2024 16:17
@jakirkham
Copy link
Member Author

Thanks Peter! 🙏

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

Successfully merging this pull request may close these issues.

2 participants