This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: No entry Deque in
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, levkivskyi, ned.deily, python-dev, rhettinger
Priority: normal Keywords: patch

Created on 2016-12-19 06:19 by rhettinger, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
Deque.diff rhettinger, 2016-12-21 06:36 Patch to add Deque review
Deque2.diff rhettinger, 2016-12-27 10:24 review
Messages (4)
msg283590 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-12-19 06:19
We have:

    # Concrete collection types.
    'NamedTuple',  # Not really a type.

But no mention of Deque.

What this an intended omission?

I would like to be able to write something like this:

   user_posts = defaultdict(deque)  # type: DefaultDict[User, Deque[Post]]
msg283591 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-12-19 06:36
FWIW, I tried "d = deque() # type: typing.MutableSequence" but this gave:

    error: MutableSequence[Post] has no attribute "appendleft"
msg283660 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-12-20 00:55
I don't recall exactly what happened here, but I think it was left out during formulation of PEP 484 because it's not an ABC.  IIRC originally we only wanted to include builtins and ABCs.  But we changed that subsequently to include e.g. DefaultDict.

I suppose we should change this now, but the cat is out of the bag for 3.6.0 and I would prefer not to change in any way between 3.6.0 and 3.5.3, so the best we could do would be to add it to 3.6.1 and 3.5.4 (whenever that will be).

In the meantime collections.deque is generic, but that's only helpful in type comments, not in annotations.

In a sense I wish we hadn't put in the stdlib, it would have been much simpler to fix this kind of issue.  OTOH there are also advantages to having it in the stdlib, and anyways, it's too late to change, so we'll just have to suck it up (I certainly am).
msg285616 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2017-01-17 06:44
New changeset dfefbf6f6c73 by Raymond Hettinger in branch '3.5':
Issue #29011:  Fix an important omission by adding Deque to the typing module.
Date User Action Args
2022-04-11 14:58:40adminsetgithub: 73197
2017-01-17 06:44:44rhettingersetstatus: open -> closed
resolution: fixed
2017-01-17 06:44:23python-devsetnosy: + python-dev
messages: + msg285616
2016-12-27 10:24:22rhettingersetfiles: + Deque2.diff
2016-12-22 22:53:30levkivskyisetnosy: + levkivskyi
2016-12-21 06:36:24rhettingersetfiles: + Deque.diff
components: + Library (Lib)
versions: + Python 3.5, Python 3.6, Python 3.7
keywords: + patch
nosy: + ned.deily

type: enhancement
stage: patch review
2016-12-20 00:55:55gvanrossumsetmessages: + msg283660
2016-12-19 07:50:25rhettingersettitle: No entry for deques in typing -> No entry Deque in
2016-12-19 06:36:08rhettingersetmessages: + msg283591
2016-12-19 06:19:33rhettingercreate