polywrap_msgpack.extensions.generic_map module
This module contains GenericMap implementation for msgpack extension type.
- class polywrap_msgpack.extensions.generic_map.GenericMap(_map: MutableMapping[K, V])[source]
Bases:
MutableMapping[K,V]GenericMap is a type that can be used to represent generic map extension type in msgpack.
Examples
>>> from polywrap_msgpack import GenericMap >>> GenericMap({1: 2, 3: 4}) GenericMap({1: 2, 3: 4}) >>> map = GenericMap({1: 2, 3: 4}) >>> map[5] = 6 >>> map GenericMap({1: 2, 3: 4, 5: 6}) >>> map[7] Traceback (most recent call last): ... KeyError: 7 >>> 7 in map False >>> 1 in map True >>> len(map) 3 >>> del map[1] >>> map GenericMap({3: 4, 5: 6}) >>> del map[7] Traceback (most recent call last): ... KeyError: 7