aboutsummaryrefslogtreecommitdiff
path: root/immutables
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2018-04-03 00:10:20 -0400
committerYury Selivanov <yury@magic.io>2018-04-03 00:10:20 -0400
commit6140967d51cd7f0ce98bbce65f3f367b62eeb91a (patch)
tree7ec46c66fca39ef9055c3630b159dd91307add59 /immutables
parent5804f0c47e60c7c2a0915cce2dbcfc7593881761 (diff)
downloadimmutables-6140967d51cd7f0ce98bbce65f3f367b62eeb91a.tar.gz
immutables-6140967d51cd7f0ce98bbce65f3f367b62eeb91a.zip
Make Map a subclass of collecitons.abc.Mapping
Diffstat (limited to 'immutables')
-rw-r--r--immutables/__init__.py3
-rw-r--r--immutables/_map.c2
-rw-r--r--immutables/map.py4
3 files changed, 8 insertions, 1 deletions
diff --git a/immutables/__init__.py b/immutables/__init__.py
index d598413..e900c2b 100644
--- a/immutables/__init__.py
+++ b/immutables/__init__.py
@@ -2,6 +2,9 @@ try:
from ._map import Map
except ImportError:
from .map import Map
+else:
+ import collections.abc as _abc
+ _abc.Mapping.register(Map)
__all__ = 'Map',
diff --git a/immutables/_map.c b/immutables/_map.c
index 3ed0393..be82cd9 100644
--- a/immutables/_map.c
+++ b/immutables/_map.c
@@ -3032,7 +3032,7 @@ static PyMappingMethods Map_as_mapping = {
PyTypeObject _Map_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "Map",
+ "immutables._map.Map",
sizeof(MapObject),
.tp_methods = Map_methods,
.tp_as_mapping = &Map_as_mapping,
diff --git a/immutables/map.py b/immutables/map.py
index b6d55dc..83c02bc 100644
--- a/immutables/map.py
+++ b/immutables/map.py
@@ -1,3 +1,4 @@
+import collections.abc
import reprlib
@@ -457,3 +458,6 @@ class Map:
buf = []
self.__root.dump(buf, 0)
return '\n'.join(buf)
+
+
+collections.abc.Mapping.register(Map)