[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-03-24 Thread Raymond Hettinger

Raymond Hettinger added the comment:


New changeset 357bad7101df196d7f4ea3dc6ed9a6436afb022c by Raymond Hettinger 
(Louie Lu) in branch 'master':
bpo-29634: Reduce deque repeat execution when maxlen exist and size is not 1 
(#255) (#255)
https://github.com/python/cpython/commit/357bad7101df196d7f4ea3dc6ed9a6436afb022c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is an opportunity of further optimisation. For example 
deque(range(10), maxlen=11) *= 2 copies 10 elements while it is 
enough to copy just 1 element. But I don't know whether it is worth to optimise 
this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

Louie Lu added the comment:

Raymond: comment has changed, pushed on to GitHub.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The code looks fine.  Please change the comment to something like:

/* Reduce the number of repetitions when maxlen would be exceeded */

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

Louie Lu added the comment:

Serhiy: yes, your advice is better than checking inside the loop.

I have updated this to the commit, thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Wouldn't be better to update the number of repeats before the loop rather than 
checking at every iteration?

if (deque->maxlen >= 0 && n * size > deque->maxlen)
n = (deque->maxlen + size - 1) / size;

--
assignee:  -> rhettinger
nosy: +rhettinger, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

Changes by Louie Lu :


--
pull_requests: +223

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29634] Reduce deque repeat execution when maxlen exist and size is not 1

2017-02-23 Thread Louie Lu

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com