-
Notifications
You must be signed in to change notification settings - Fork 114
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
Avoid the overhead of creating a PyErr for downcasting. #326
Conversation
40b727c
to
dee5c3a
Compare
I'm not sure how it matters in user experience. Anyway users can't get the enum and just get |
dee5c3a
to
cbb3c1c
Compare
The difference is purely internal w.r.t. performance, but it actually turns out to be a mixed bag after adding the benchmarks (I guess the enum is larger than
I therefore redid the whole thing using a more tricky This, together with checking pointer equality before calling into
|
The hack in |
Yes, it is used only for So as indicated by the Finally, failed calls to |
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.
Thank you for your explanation. Let's land this PR after documenting the internal usage a bit.
cbb3c1c
to
3795010
Compare
Hmm, the pypy failure looks like a bug of maturin 😓 |
Reported at PyO3/maturin#882 |
Will hold back on merging until Maturin 0.12.14 is released so that I can drop the last commit. |
af79124
to
3795010
Compare
This does give us the best of both worlds, i.e. avoid having to create a
PyErr
for downcast but still keeping a single implementation for theextract
logic. I am just not sure whether this is wort the additional effort, i.e. the extraExtractionError
enum.