diff options
author | Ofek Lev <ofekmeister@gmail.com> | 2021-02-09 15:32:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-09 14:32:01 -0600 |
commit | 8af150216acfc2a900c648ade713df947b903970 (patch) | |
tree | 23ca32580a8547c9604713392fa5707b19463691 /immutables | |
parent | d7f3eebbc1b8b2d06633dacd4c81de1386b9b3fa (diff) | |
download | immutables-8af150216acfc2a900c648ade713df947b903970.tar.gz immutables-8af150216acfc2a900c648ade713df947b903970.zip |
Make __repr__ more similar to other mapping types (#58)
Diffstat (limited to 'immutables')
-rw-r--r-- | immutables/_map.c | 14 | ||||
-rw-r--r-- | immutables/map.py | 6 |
2 files changed, 4 insertions, 16 deletions
diff --git a/immutables/_map.c b/immutables/_map.c index 9f0a586..7e510fd 100644 --- a/immutables/_map.c +++ b/immutables/_map.c @@ -3194,14 +3194,14 @@ map_py_repr(BaseMapObject *m) if (MapMutation_Check(m)) { if (_PyUnicodeWriter_WriteASCIIString( - &writer, "<immutables.MapMutation({", 25) < 0) + &writer, "immutables.MapMutation({", 24) < 0) { goto error; } } else { if (_PyUnicodeWriter_WriteASCIIString( - &writer, "<immutables.Map({", 17) < 0) + &writer, "immutables.Map({", 16) < 0) { goto error; } @@ -3255,16 +3255,6 @@ map_py_repr(BaseMapObject *m) goto error; } - PyObject *addr = PyUnicode_FromFormat(" at %p>", m); - if (addr == NULL) { - goto error; - } - if (_PyUnicodeWriter_WriteStr(&writer, addr) < 0) { - Py_DECREF(addr); - goto error; - } - Py_DECREF(addr); - Py_ReprLeave((PyObject *)m); return _PyUnicodeWriter_Finish(&writer); diff --git a/immutables/map.py b/immutables/map.py index 7c16139..fe9dbaf 100644 --- a/immutables/map.py +++ b/immutables/map.py @@ -649,8 +649,7 @@ class Map: items = [] for key, val in self.items(): items.append("{!r}: {!r}".format(key, val)) - return '<immutables.Map({{{}}}) at 0x{:0x}>'.format( - ', '.join(items), id(self)) + return 'immutables.Map({{{}}})'.format(', '.join(items)) def __dump__(self): # pragma: no cover buf = [] @@ -818,8 +817,7 @@ class MapMutation: items = [] for key, val in self.__root.items(): items.append("{!r}: {!r}".format(key, val)) - return '<immutables.MapMutation({{{}}}) at 0x{:0x}>'.format( - ', '.join(items), id(self)) + return 'immutables.MapMutation({{{}}})'.format(', '.join(items)) def __len__(self): return self.__count |