You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Converting collections.deque methods to Argument Clinic #85533
See also bpo-20180. collections.deque was intentionally not converted to Argument Clinic, but some of methods were made using more efficient code for parsing arguments by inlining the code generated by Argument Clinic at that time.
Now Argument Clinic generates more efficient (but more cumbersome) code, so there may be new reasons of using it. Please test the performance of the deque constructor (deque(), deque(()), deque((), 10), deque((), maxlen=10)), methods index() and rotate(), builtins iter() and reversed(). It is hard to test insert() because it mutates the deque and I do not expect anything beside noise for other methods.
Go ahead with in-lining the argument handling for rotate(). The no argument form and the +1 and the -1 case are important enough to warrant the change.
Please skip index() and insert() which aren't essential methods. Also, those methods aren't called with end-point specific arguments, so the argument processing time doesn't dominate and it isn't worth it.
Activity
corona10 commentedon Jul 21, 2020
There was no performance regressin with this change.
serhiy-storchaka commentedon Jul 21, 2020
See also bpo-20180. collections.deque was intentionally not converted to Argument Clinic, but some of methods were made using more efficient code for parsing arguments by inlining the code generated by Argument Clinic at that time.
corona10 commentedon Jul 22, 2020
Oh, I see ..
serhiy-storchaka commentedon Jul 22, 2020
Now Argument Clinic generates more efficient (but more cumbersome) code, so there may be new reasons of using it. Please test the performance of the deque constructor (deque(), deque(()), deque((), 10), deque((), maxlen=10)), methods index() and rotate(), builtins iter() and reversed(). It is hard to test insert() because it mutates the deque and I do not expect anything beside noise for other methods.
rhettinger commentedon Jul 22, 2020
I think we should skip applying the clinic to the code. It jumbles the code quite a bit but doesn't give any real benefit.
sweeneyde commentedon Mar 7, 2021
If the argument clinic is too disruptive, would it be okay to inline the equivalent code like this?
Benchmarks for this change:
Similar changes could apply to deque.insert() and deque.index().
rhettinger commentedon Mar 9, 2021
Go ahead with in-lining the argument handling for rotate(). The no argument form and the +1 and the -1 case are important enough to warrant the change.
Please skip index() and insert() which aren't essential methods. Also, those methods aren't called with end-point specific arguments, so the argument processing time doesn't dominate and it isn't worth it.
rhettinger commentedon Mar 16, 2021
New changeset 448801d by Dennis Sweeney in branch 'master':
bpo-41361: Optimized argument parsing for deque_rotate (GH-24796)
448801d
rhettinger commentedon Mar 16, 2021
Thanks for the PR :-)