Commit 357bad71 authored by Louie Lu's avatar Louie Lu Committed by Raymond Hettinger

bpo-29634: Reduce deque repeat execution when maxlen exist and size is not 1 (#255) (#255)

parent abb3b8ad
......@@ -731,6 +731,10 @@ deque_inplace_repeat(dequeobject *deque, Py_ssize_t n)
if (seq == NULL)
return seq;
/* Reduce the number of repetitions when maxlen would be exceeded */
if (deque->maxlen >= 0 && n * size > deque->maxlen)
n = (deque->maxlen + size - 1) / size;
for (i = 0 ; i < n-1 ; i++) {
rv = deque_extend(deque, seq);
if (rv == NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment