[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)

[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. --

[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 ___

[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 ___ ___

[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

[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

[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,

[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

[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.