Issue 17394: Add slicing support to collections.deque (original) (raw)

Created on 2013-03-11 03:20 by rhettinger, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
deque_slices.patch serhiy.storchaka,2016-01-05 12:11 review
deque_slices_2.patch serhiy.storchaka,2016-01-27 07:42 review
deque_slices_3.patch serhiy.storchaka,2016-03-07 08:04 review
Messages (16)
msg183918 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-03-11 03:20
Once added, use it in threading.Condition().
msg190873 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-06-09 20:34
The slicing support can be implemented using just rotates, appends, and pops.
msg197578 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-09-13 14:15
What type should be a result of slicing? List, tuple, deque, other?
msg243029 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2015-05-13 01:01
For the record, Raymond asked for permission to check this in (a new feature) for 3.5 beta 2, as he won't have time to finish it before beta 1. As 3.5 release manager I've given him permission. Go Raymond!
msg257460 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-04 11:56
Proposed patch implements getting, deleting and setting slices in deque. Getting a slice returns a list, but this can be changed if needed.
msg258997 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-27 07:42
Synchronized with current sources and added mandatory now braces.
msg259001 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-01-27 08:31
Thank you for doing this work.
msg259070 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2016-01-27 22:56
It seems odd to have a slice of a deque return a list. Are there any other examples of non-buffer protocol objects behaving like this in the standard library/built-ins? Only examples I can come up with are mmap objects and ctypes arrays (which are making raw binary data available in Python); it seems rather surprising that a Python level type like deque would slice to produce a list.
msg259089 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-01-28 04:04
Returning a deque is preferred. For this stage, I just want to review the code and make sure it algorithmically correct (slicing is complicated and has a lot of cases).
msg259810 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-07 23:33
Since the patch is so complex, I suggest to split it on parts, and review and commit them separately: 1) Refactoring. Extract common code to macros and utility functions. These macros can be used for more efficient implementing insert() and __del__. 2) Add slice getting. 3) Add slice assignment and deleting. I'm not sure that this is needed for deque.
msg259812 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-02-08 01:23
I'm already underway for the review. The "refactoring" part is making is more difficult. We just need slicing support to be added. Yes, I do want slice assignment and deletion. The output should be a deque, not a list.
msg261285 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-07 08:04
The output now is a deque.
msg267777 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-08 04:44
Raymond, do you have a time to make a review?
msg272766 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-08-15 15:01
Raymond, do you still have an interest in this issue? If no, you can just close it.
msg275180 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-08 21:50
Ping.
msg275505 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-09-10 00:07
> If no, you can just close it. Yes, I would rather close this than apply this patch.
History
Date User Action Args
2022-04-11 14:57:42 admin set github: 61596
2016-09-10 00:07:04 rhettinger set status: open -> closedresolution: rejectedmessages: +
2016-09-08 21:50:09 serhiy.storchaka set messages: +
2016-08-15 15:01:17 serhiy.storchaka set messages: +
2016-06-08 04:44:48 serhiy.storchaka set messages: +
2016-03-07 08:04:21 serhiy.storchaka set files: + deque_slices_3.patchmessages: +
2016-02-08 01:23:14 rhettinger set messages: +
2016-02-07 23:33:17 serhiy.storchaka set messages: +
2016-01-28 04:04:46 rhettinger set messages: +
2016-01-27 22:56:58 josh.r set nosy: + josh.rmessages: +
2016-01-27 08:31:50 rhettinger set messages: +
2016-01-27 07:42:30 serhiy.storchaka set files: + deque_slices_2.patchmessages: +
2016-01-05 12:11:34 serhiy.storchaka set files: + deque_slices.patch
2016-01-05 12:11:19 serhiy.storchaka set files: - deque_slices.patch
2016-01-04 16:14:10 serhiy.storchaka set files: + deque_slices.patch
2016-01-04 16:13:56 serhiy.storchaka set files: - deque_slices.patch
2016-01-04 11:56:45 serhiy.storchaka set files: + deque_slices.patchversions: + Python 3.6, - Python 3.5messages: + assignee: rhettingerkeywords: + patchstage: needs patch -> patch review
2015-05-13 01:01:41 larry set messages: +
2015-05-13 00:57:28 larry set nosy: + larry
2014-02-01 00:02:35 yselivanov set versions: + Python 3.5, - Python 3.4
2013-09-13 14:15:10 serhiy.storchaka set messages: +
2013-06-09 20:34:10 rhettinger set priority: low -> normaltype: enhancementassignee: rhettinger -> (no value)nosy: + serhiy.storchakamessages: + stage: needs patch
2013-03-11 03:55:12 jcea set nosy: + jcea
2013-03-11 03:20:21 rhettinger create