-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Minor performance tweak for deque.index() with a start argument #9440
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1050,8 +1050,10 @@ deque_index(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs) | |
start = stop; | ||
assert(0 <= start && start <= stop && stop <= Py_SIZE(deque)); | ||
|
||
/* XXX Replace this loop with faster code from deque_item() */ | ||
for (i=0 ; i<start ; i++) { | ||
for (i=0 ; i < start - BLOCKLEN ; i += BLOCKLEN) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP 7 requires spaces around There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use your talents to focus on something relevant. Over-aggressive interpretations of PEP 7 are waste of time. |
||
b = b->rightlink; | ||
} | ||
for ( ; i < start ; i++) { | ||
index++; | ||
if (index == BLOCKLEN) { | ||
b = b->rightlink; | ||
|
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.
Is
leftindex == 0
in this case? Would be nice to test also cases whenleftindex != 0
and when(leftindex + start) % BLOCKLEN < leftindex
.