-
Notifications
You must be signed in to change notification settings - Fork 763
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
optimize sequence conversion for list and tuple #2944
Conversation
@ritchie46 would you be willing to run your benchmark suite built against this branch to verify this resolves the issue? If so, we can prepare 0.18.2 patch release with this in a week or two. |
Yeap, seems much better; 👍
|
Great - so I agree with you @adamreichold that it won't solve the general case (and all the discussion in #2943 about not needing I still think this optimization seems worth it for a common case? |
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.
I still think this optimization seems worth it for a common case?
Agreed. (I have not yet messaged bors to give the others a change to weigh in.)
Do we have a benchmark for this? We should catch similar regressions in the future. |
I agree that a benchmark would be helpful but I don't think this is an unexpected regression. I think everybody involved in the review expected this to decrease performance with the memoization of the |
👍 I'll push a benchmark within a day or two. |
Benchmark pushed. On my machine these drop from the 100-200ns range to about 2ns 😄 |
Wow... That that's 1-3 cpu cycles 🙈 |
Yes, checking for lists and tuples (and subclasses) can be done by checking for a bit set on the type object. I should probably push a similar PR for dicts & mapping. |
b64200e
to
4a41917
Compare
Think we've given others a few days, I'd like to prep the next patch release soon. bors r=adamreichold |
Build succeeded: |
Sounds fantastic, can't wait to give it a spin! Thanks to everyone involved! |
closes #2943
Avoid using
PyObject_IsInstance
for checking if lists or tuples are sequences, as we know they are always sequences.