-
Notifications
You must be signed in to change notification settings - Fork 2.2k
pytypes: Add Gotchas section about default-constructed wrapper types and py::none() #2362
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
pytypes: Add Gotchas section about default-constructed wrapper types and py::none() #2362
Conversation
This is the "document the status quo" solution. I'm a bit fearful about changing the behavior just yet, but will speak more to that in the issue. |
0a31d0e
to
4577989
Compare
Man... trying to explain this contract and compare against other languages was a bit of a fun exercise... |
I also find this very confusing, actually. What's happening:
So actually, I don't see what's wrong/broken in pybind11, and what should need explaining. This addition to the docs seems disproportionally large to me, for what's basically consistent behavior (pybind11-bound functions are consistent with Python, C++ functions are consistent with C++)? This PR seems to add to the confusion between the actual "C++ interface for Python" with the "overload resolution of bound functions to Python". I also strongly object against mentioning Java and C# in our docs. This is about Python and C++, and they both have a different way of handling variable. Basically, Java and C# (non-primitive) variables are all pointers and those pointers can be a null pointer. Python variables work differently, since you bind a name to an object. And the singleton NB: |
I'm down for reducing the volume of the text, but I do feel that it's an edge case worth mentioning. We've spent time hashing out this behavior here and in the issue, so I believe that is sufficient evidence that it does need explaining, but perhaps more briefly.
I'm good with that. I intended to capture this as a rather complex contract, but yes, relating to Java or C# may confuse the point further.
Good point!
Yup! Hence only capturing this as documentation, rather than vying for a change in functionality. |
4c697b9
to
dc9e30d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, my original comment/review was quite harsh, looking back at it, now. Sorry :-|
But I do like this better, actually. It feels like less of a single use-case story, and more to the point.
Thanks for actually creating this PR, @EricCousineau-TRI! :-)
# Conflicts: # docs/advanced/pycpp/object.rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Eric!
Resolves #2361 (through docs)