Replies: 2 comments 1 reply
-
@drexlerd this is a really great question. I hope that I understand it well (or maybe to well)... but have you ever seen a "constant list" in Python? This is a long lasting question of immutable containers. I have encountered same questions in my work with pybind... so in short, it is a little bit deeper than pybind itself. Here is some background story:
Afaik pybind always tries to be in-line with Python as much as possible. As Python does not expose anything like frozenlist, so do pybind. Pybind as a binding library, is not required to create "standard objects" of any type to suplement well-known standard library of Python. I also wish that such frozen-alternatives exist but even in Python you need to write them yourself. Although it could be great to have "templated approach" that utilise the Hope that gives you some insight of the complicated world of frozen-containers of Python. What is your view on this? Cheers! |
Beta Was this translation helpful? Give feedback.
-
@jiwaszki I highly appreciate your detailed response and the pointers. I still have to process parts of it but I have a thought on this already.
It could also be the other way around, i.e., being as much as possible in-line with C++. Ultimately, our goal is to make C++ implementations available from the Python side and not the other way around. For example, when returning a |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am returning a
const std::vector<const T*>
and declaredstd::vector<const T*>
as opague type and used bind_vector to declare the bindings. Unfortunately this adds modifiers, allowing users to overwrite internal memory, by appending elements to the vector.After checking the source code, there is no way on how to make the vector behave like a const vector. I am thinking of adding bind_const_vector` that does not create modifiers of any kind. Is that the correct solution of am I missing something?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions