-
Notifications
You must be signed in to change notification settings - Fork 768
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
#[pyo3(get)] much slower than python attribute access #4247
Comments
When using A strictly apples-to-apples comparison would be a |
Hmm I appreciate the suggestion but can't seem to get that to behave any differently. I now have
and get pretty much the same result:
Perhaps I'm not understanding your suggestion correctly? |
I attempted to reproduce this locally, and I find that the difference is much smaller than you're finding. Did you compile with
PyO3 0.22 is expected to be faster still, I get numbers more like this:
I find the same as you; I think this is because constructing a Python zero from a Rust zero is also extremely cheap. But I still find the slowdown to be only 2x rather than 12x. I'm going to do a quick bit of profiling and see if I can understand and close the gap... |
Ok, so I did some experimentation and if I teach Python to read directly from a
I did the same trick for the Rust I also think that this provides us a nice solution to the lack of I think we cannot apply the same optimization for |
Ah - you're totally right - I wasn't passing
I'm much closer now. Can you show me how you're using Appreciate all the help! |
So We don't really have a point in the |
I think with #4254 released in 0.22 this is essentially solved as much as it can be. There's maybe a short follow-up to add more types beyond |
I have the following setup:
and
When I run bench I find that the rust attribute access is much slower than the python direct access.
Its unclear whether this is intended or not. Is there a good way for me to replicate the performance of python here?
If its useful:
The text was updated successfully, but these errors were encountered: