Skip to content

add the method index to collections.deque #54268

Closed

Description

@SimonLiedtke
BPO 10059
Nosy @rhettinger, @ned-deily

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 2010-10-10.10:57:31.356>
created_at = <Date 2010-10-10.00:23:45.859>
labels = ['extension-modules', 'type-feature']
title = 'add the method `index` to collections.deque'
updated_at = <Date 2010-10-10.10:57:31.355>
user = 'https://bugs.python.org/SimonLiedtke'

bugs.python.org fields:

activity = <Date 2010-10-10.10:57:31.355>
actor = 'Simon.Liedtke'
assignee = 'rhettinger'
closed = True
closed_date = <Date 2010-10-10.10:57:31.356>
closer = 'Simon.Liedtke'
components = ['Extension Modules']
creation = <Date 2010-10-10.00:23:45.859>
creator = 'Simon.Liedtke'
dependencies = []
files = []
hgrepos = []
issue_num = 10059
keywords = []
message_count = 5.0
messages = ['118296', '118297', '118304', '118305', '118333']
nosy_count = 4.0
nosy_names = ['rhettinger', 'ned.deily', 'stutzbach', 'Simon.Liedtke']
pr_nums = []
priority = 'low'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue10059'
versions = ['Python 3.2']

Activity

  1. SimonLiedtke commented on Oct 10, 2010

    SimonLiedtkemannequin
    MannequinAuthor

    I'd like to have the method index not only for list, but also for collections.deque.

    Here is my attempt: http://bitbucket.org/derdon/hodgepodge/src/tip/extended_deque.py

    I'm looking forward to see this method implemented in the stdlib!

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancement
    on Oct 10, 2010
  3. ned-deily commented on Oct 10, 2010

    @ned-deily
    Member

    Since you are requesting adding a method to an existing data type, you should probably raise this issue first on the python-ideas mailing list and be prepared to justify use cases for it.

    http://mail.python.org/mailman/listinfo/python-ideas

  4. rhettinger commented on Oct 10, 2010

    @rhettinger
    Contributor

    The absence of index() from collections deque wasn't an oversight. Deques are not really about indexed access, they are about appending and popping from the ends. I'm curious about your use case and whether it is a good match for this data structure.

  5. added and removed
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 10, 2010
  6. self-assigned this
    on Oct 10, 2010
  7. stutzbach commented on Oct 10, 2010

    stutzbachmannequin
    Mannequin

    Hello Simon,

    Accessing an arbitrary element of a deque takes O(n) time, making your .index implementation O(n**2).

    If you describe the kinds of operations that you need to perform efficiently, we may be able to suggest a better data structure for you to use.

  8. SimonLiedtke commented on Oct 10, 2010

    SimonLiedtkemannequin
    MannequinAuthor

    I see that adding this method to a deque is useless. A list is better for this kind of operation. I just wrote it for fun and realized that it was implemented rather slow.

  9. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions