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

Extend py::class for non-const readwrite #257

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

sarlinpe
Copy link
Collaborator

The getter of def_readwrite returns a const reference, which makes numpy arrrays non-writeable. This makes it impossible to write:

p = pycolmap.Point3D(xyz=...)
...
p.xyz += 1

This PR transparently makes def_readwrite return a non-const reference for some extended classes py::class_ext_.

@sarlinpe sarlinpe changed the title Extended py::class for nonconst read Extend py::class for nonconst read Jan 26, 2024
@sarlinpe sarlinpe changed the title Extend py::class for nonconst read Extend py::class for non-const readwrite Jan 26, 2024
@sarlinpe sarlinpe merged commit 3b6b8fe into master Jan 26, 2024
6 checks passed
@sarlinpe sarlinpe deleted the sarlinpe/fix-readwrite-const branch January 26, 2024 14:37
@nnop
Copy link
Contributor

nnop commented Jan 31, 2024

You are such a pybind11 guru. How did you achieve so deep techs of manipulating pybind11?

@sarlinpe
Copy link
Collaborator Author

I spent too much time reading the pybind source code 😅

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

Successfully merging this pull request may close these issues.

3 participants