[Python-Dev] Intended Usage of collections.abc for Custom Collections
jab at math.brown.edu
jab at math.brown.edu
Wed Oct 28 11:45:31 EDT 2015
More information about the Python-Dev mailing list
Wed Oct 28 11:45:31 EDT 2015
- Previous message (by thread): [Python-Dev] Bytcode "magic tag"
- Next message (by thread): [Python-Dev] Intended Usage of collections.abc for Custom Collections
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Dear Python-Dev, I am the author of bidict, a bidirectional map implementation for Python. A user recently filed a bug that bidict should be a subclass of dict, so that isinstance(mybidict, dict) would return True. I replied that the user should instead use isinstance(mybidict, collections.abc.Mapping), which does already return True, and is more polymorphic to boot. But before I put the issue to bed, I want to make sure I'm correctly understanding the intended usage of collections.abc, as well as any relevant interfaces I'm not currently using (collections.UserDict? __subclasshook__?), since the documentation leaves me with some doubt. Could any collections experts on this list please confirm whether bidict is implemented as the language intends it should be? Some quick references: https://bidict.readthedocs.org/en/latest/other-bidict-types.html#bidict-type-hierarchy https://github.com/jab/bidict/blob/master/bidict/_bidict.py I would be happy to try to capture what I learn from this thread and write up a guide for collections library authors in the future, or otherwise pay your help forward however I can. Thanks and best wishes. -jab -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20151028/455824ef/attachment.html>
- Previous message (by thread): [Python-Dev] Bytcode "magic tag"
- Next message (by thread): [Python-Dev] Intended Usage of collections.abc for Custom Collections
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list