colmap / pycolmap

Python bindings for COLMAP
BSD 3-Clause "New" or "Revised" License
858 stars 125 forks source link

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

Closed sarlinpe closed 5 months ago

sarlinpe commented 5 months ago

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_.

nnop commented 4 months ago

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

sarlinpe commented 4 months ago

I spent too much time reading the pybind source code 😅