-
Notifications
You must be signed in to change notification settings - Fork 792
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
2.5/3x
Performance regression with PySequence as PyTryFrom
since 0.16
.
#2943
Comments
2.5/3x
Performance regression function dispatch since 0.16
.2.5/3x
Performance regression with PySequence as PyTryFrom
since 0.16
.
Thanks for the repro. It looks like this is due to the changes to We can optimise the common case for lists and tuples. I'll push a PR in a second. |
While that does not change that You do not appear to be using the PySequence API in that module. So personally, it would seem that there is no reason to perform that downcast in the first place which should also imply better performance than even the previous implementation provided by PyO3. |
Right, I did not get back to this @adamreichold, you are right. Why is going through |
I don't think that actually calling methods on The main point is that in your conversion methods, the only method you seem to be calling is So long story short, you don't need the @davidhewitt I am also not sure if special-casing lists and tuples would be sufficient to resolve the regression. While the bug report involved tuples, I suspect that for example NumPy arrays are a reasonably frequent argument type and checking in the same manner for that would require calling into NumPy's capsule API. |
Thanks for the rationale @adamreichold. I will drop the |
@ritchie46 Maybe to give some context as to why the downcasting got slower: It is more strict now checking that a type actually implements |
This has been reported downstream in pola-rs/polars#6791
It seems that dispatch to a very simple function has got a lot more expensive. Take this simple program:
And running this snippet with a release build:
This takes:
Cargo.toml
The text was updated successfully, but these errors were encountered: