Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make deques a full MutableSequence by adding index(), insert(), and copy() #67892

Closed
rhettinger opened this issue Mar 19, 2015 · 7 comments
Closed
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@rhettinger
Copy link
Contributor

rhettinger commented Mar 19, 2015

BPO 23704
Nosy @rhettinger, @serhiy-storchaka
Files
  • deque_insert_index_copy3.diff: First draft -- needs doc update and more tests
  • deque_insert_index_copy4.diff: With docs and test
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/rhettinger'
    closed_at = <Date 2015-03-21.08:39:04.408>
    created_at = <Date 2015-03-19.07:11:27.424>
    labels = ['type-feature', 'library']
    title = 'Make deques a full MutableSequence by adding index(), insert(), and copy()'
    updated_at = <Date 2015-03-21.09:28:50.300>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2015-03-21.09:28:50.300>
    actor = 'serhiy.storchaka'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2015-03-21.08:39:04.408>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2015-03-19.07:11:27.424>
    creator = 'rhettinger'
    dependencies = []
    files = ['38552', '38617']
    hgrepos = []
    issue_num = 23704
    keywords = ['patch']
    message_count = 7.0
    messages = ['238761', '238765', '238769', '238771', '238776', '238777', '238779']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23704'
    versions = ['Python 3.5']

    @rhettinger rhettinger added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Mar 19, 2015
    @rhettinger rhettinger self-assigned this Mar 19, 2015
    @rhettinger
    Copy link
    Contributor Author

    rhettinger commented Mar 21, 2015

    Attaching an updated patch with documentation updates and tests.

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented Mar 21, 2015

    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.

    @rhettinger
    Copy link
    Contributor Author

    rhettinger commented Mar 21, 2015

    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.

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented Mar 21, 2015

    Then the patch LGTM except few nitpicks.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 21, 2015

    New changeset 3d33be07c5a2 by Raymond Hettinger in branch 'default':
    bpo-23704: Add index(), copy(), and insert() to deques. Register deques as a MutableSequence.
    https://hg.python.org/cpython/rev/3d33be07c5a2

    @rhettinger
    Copy link
    Contributor Author

    rhettinger commented Mar 21, 2015

    Thank you for looking it over.

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented Mar 21, 2015

    Did you noticed my comments on Rietveld? You can found Rietveld messages in the Spam folder.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants