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

Document that struct binding getters return a copy of a value and propagating any changes must go through the setter #262

Open
vzhurba01 opened this issue Dec 3, 2024 · 1 comment · May be fixed by #413
Assignees
Labels
cuda.bindings Everything related to the cuda.bindings module documentation Improvements or additions to documentation P1 Medium priority - Should do

Comments

@vzhurba01
Copy link
Collaborator

https://github.com/NVIDIA/cuda-python/pull/261/files/4abe5206ac75224a1e03a1198a10f1daa5eec2f0#r1867071402

As uncovered here, there's a lack of clarity in how attributes get packaged for Cython's Extension Types. While the bindings outwardly presents their attributes in a Pythonic way, they can't always be interacted with in a Pythonic style. Often the getters/setters is actually a translation step to convert values between Python and C.

In this specific example, the setter makes sure that the Python list elements are packages in a contiguous memory for C consumption. The getter returns a copy of each element in a Python list. Both behaviors are unnatural for Python users and we should document that there's an emphasis to use the getter/setter directly.

@vzhurba01 vzhurba01 added cuda.bindings Everything related to the cuda.bindings module documentation Improvements or additions to documentation P1 Medium priority - Should do labels Dec 3, 2024
@vzhurba01 vzhurba01 added the triage Needs the team's attention label Dec 4, 2024
@leofang leofang added this to the cuda-python 12-next, 11-next milestone Jan 18, 2025
@leofang leofang removed the triage Needs the team's attention label Jan 18, 2025
@leofang
Copy link
Member

leofang commented Jan 18, 2025

Let's see if we can work on this during code freeze.

@ksimpson-work ksimpson-work linked a pull request Jan 23, 2025 that will close this issue
@ksimpson-work ksimpson-work linked a pull request Jan 23, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda.bindings Everything related to the cuda.bindings module documentation Improvements or additions to documentation P1 Medium priority - Should do
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants