[New-bugs-announce] [issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

Louie Lu report at bugs.python.org
Thu Feb 23 11:39:23 EST 2017


New submission from Louie Lu:

There is a XXX in v3.5.0 shows that need to dealing with deque maxlen setting case in deque_repeat.

Although there have common case for deque size 1 with maxlen, other size of deque with maxlen still using for-loop to extend the deque, without any detection.

Adding this fast break will reduce the execution speed when repeat deque with maxlen.

---
$ cat tests.py
from collections import deque
for _ in range(10:
    d = deque(maxlen=100_000)
    d.insert(0, 0)
    d.insert(0, 10)
    d * 10_000_000
$ time ./python_with_patch tests.py
$ time ./python tests.py

----------
components: Extension Modules
messages: 288460
nosy: louielu
priority: normal
severity: normal
status: open
title: Reduce deque repeat execution when maxlen exist and size is not 1
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29634>
_______________________________________


More information about the New-bugs-announce mailing list