-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Priority overload #1131
Priority overload #1131
Conversation
529ce3e
to
a331f96
Compare
Although I understand the motivation, I'm not in favor of this modification, which further increases the runtime cost and complexity of an already very complex dispatch routine. I think that we ought to make this part of pybind11 shorter and faster, not the other way. |
Does this increase the runtime? All it does is allow someone to attach a function at the beginning of the overload chain instead of the end, but the overload chain is the same length either way. It doesn't even increase the size of the struct, since there's one bit left over for alignment. So in the setup (runtime) phase, it adds one if statement. This functionality seems useful in a more general case, where a user needs to pre-insert a call. But up to you. |
Aha -- I misread the patch in that case. I was assuming that the priority tag was handled in the method dispatch function, but I see now that it is in the part of the code that creates Python function overloads. I've recently heard from users who found that Boost.Python dispatches methods faster than pybind11 (!?!?), which still has me a bit concerned that we are piling on too much stuff. |
One naming suggestion: how about calling it |
I took the name from the original comment from @jagerman, I don't think he meant it to be final. I like Unrelated: Any numbers or profile code for the boost Python comparison? |
|
57e1fe2
to
034e13d
Compare
Unfortunately we don't currently have a good way of tracking performance over time, which is a bit of a concern. It would be nice to have a CI to catch performance regressions similarly to how we catch bugs with Travis and friends. I played around with Unladen Swallow at some point but haven't had enough free clock cycles to turn it into something useful. |
I've pushed a commit to your branch that ought to get this working (a86451d). Basically the start of the chain was only being half-updated: it also needed to be updated inside the |
FYI, I'll polish off the tests as soon as I get a chance, hopefully around this weekend. |
0e710b7
to
7077961
Compare
7077961
to
35a3016
Compare
@jagerman That was a very long weekend, but it should be ready for review finally! |
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.
Two very minor comments, aside from those it looks good to me.
35a3016
to
1c2f982
Compare
1c2f982
to
8308930
Compare
Could this be useful in 2.3.0? |
8308930
to
63d9c93
Compare
a279e67
to
4b1a38a
Compare
Maybe we could also add a mention in the upgrade guide that |
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.
Looks great! I have just some minor naming suggestions.
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.
Should be rather painless, I think, yes :-)
4b1a38a
to
403a532
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.
This PR was included in Google-global testing: no issues found.
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.
The implementation looks all good to me, but documentation could be improved IMO.
(Really sorry that this has been stuck here in 2017. The flurry of recent activity has been wonderful -- thank you for all of your help! @henryiii @YannickJadoul @bstaletic @rwgk @EricCousineau-TRI and @ax3l) |
My vote would also go for I feel less strongly about the following: For consistency, we could also have a |
FWIW, I would be in favor of adding a |
d34a67a
to
92268fd
Compare
92268fd
to
dd862c2
Compare
Adds
py::prepend()
as an optional tag when defining a function, which causes an added function to be prepended to the beginning of the overload chain. This can be used to override a default constructor that was provided earlier, for example. When combined with #1122, this will allow the default string (or the old int) constructors for enums to be replaced by users.No performance penalty, it just prepends instead of appends to the call chain. Provides a possible solution to, and docs for, so closes #2537, so targeting 2.6.0 (related to the original use case, actually :) )
Also adds
get_pointer
/set_pointer
forpy::capsule
.