Browse Source

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

pull/270/head
Louie Lu 9 years ago
committed by Raymond Hettinger
parent
commit
357bad7101
  1. 4
      Modules/_collectionsmodule.c

4
Modules/_collectionsmodule.c

@ -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) {

Loading…
Cancel
Save