-
Notifications
You must be signed in to change notification settings - Fork 2.2k
std::vector from py::iterable #1773
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
Comments
I had the same issue (I think): if C++
Python
the last line raises |
+1 on the front of any stl container type (e.g. Maybe better is just being explicit. At present, you could do:
but that does defeat element-wise type-checking. Then something like |
My initial attempt to encode this in dowstream lib is here: |
PyCLIF supports this: https://source.corp.google.com/piper///depot/google3/third_party/clif/python/stltypes.h;l=894;bpv=1;rcl=446801735. The feature request is tracked at pybind/pybind11#1773. Also change type caster of `PyObject` so that it does not own the Python object. Otherwise I see some weird test failures related to gc: http://sponge2/c868d236-550c-4fe5-8d41-0d9ebb8aaf38 (Failed). PiperOrigin-RevId: 462463815
At the moment
list_caster
instl.h
explicitly checks whether the input argument is asequence
, but I would like to argue that that's slightly too restrictive anditerable
should be accepted.The only potential downside I can think of is that generators should definitely not be accepted as a failed conversion of an element halfway through the generator would leave things in a terrible state, but a well-placed
PyGen_Check
could prevent that.The text was updated successfully, but these errors were encountered: