classification
Title: Make deques a full MutableSequence by adding index(), insert(), and copy()
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: python-dev, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-03-19 07:11 by rhettinger, last changed 2015-03-21 09:28 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
deque_insert_index_copy3.diff rhettinger, 2015-03-19 07:11 First draft -- needs doc update and more tests review
deque_insert_index_copy4.diff rhettinger, 2015-03-21 04:40 With docs and test review
Messages (7)
msg238761 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015-03-21 04:40
Attaching an updated patch with documentation updates and tests.
msg238765 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-21 05:26
When appending fails, the deque is left in changed state. I would do it in different way. First append new item (can fail), and then make circular shift (never fail). This also should be faster (up to 2 times). Most code can be shared between rotate() and circular shift operation.
msg238769 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015-03-21 07:41
For now, I prefer to continue using rotate() as a primitive and am saving circular shifts for another day (likely when I start working on slices).

FWIW, the only way for append() to fail is a memory error; in which case, I would ilke to stop doing any work at alll and return a soon as possible, even if it means leaving the deque in a reordered state.
msg238771 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-21 07:45
Then the patch LGTM except few nitpicks.
msg238776 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-21 08:37
New changeset 3d33be07c5a2 by Raymond Hettinger in branch 'default':
Issue 23704:  Add index(), copy(), and insert() to deques.  Register deques as a MutableSequence.
https://hg.python.org/cpython/rev/3d33be07c5a2
msg238777 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015-03-21 08:39
Thank you for looking it over.
msg238779 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-21 09:28
Did you noticed my comments on Rietveld? You can found Rietveld messages in the Spam folder.
History
Date User Action Args
2015-03-21 09:28:50serhiy.storchakasetmessages: + msg238779
2015-03-21 08:39:04rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg238777
2015-03-21 08:37:48python-devsetnosy: + python-dev
messages: + msg238776
2015-03-21 07:45:17serhiy.storchakasetmessages: + msg238771
2015-03-21 07:41:12rhettingersetmessages: + msg238769
2015-03-21 05:26:49serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg238765
2015-03-21 04:40:10rhettingersetfiles: + deque_insert_index_copy4.diff

messages: + msg238761
2015-03-19 07:26:16rhettingersetassignee: rhettinger
2015-03-19 07:11:27rhettingercreate