h5.archive.DictNonStrKey

class h5.archive.DictNonStrKey(ob)[source]

Archive wrapper for a Python dict with non-string keys.

Stored in the same layout as a C++ std::map with non-string keys (format tag "DictNonStrKey"): each (key, value) pair is written into a numbered subgroup holding a key and a val. The key is stored raw – a scalar key as a scalar dataset, a tuple key as a Tuple subgroup – so a dict with homogeneous keys is byte-compatible with the corresponding C++ std::map<Key, T> (an int-keyed dict with std::map<long, T>, a pair-keyed dict with std::map<std::pair<...>, T>, etc.) and round-trips back to the identical mapping.

Keys may be scalars or tuples of scalars and may be mixed within one dict; a mixed dict round-trips in Python but has no single C++ std::map counterpart. String-keyed dicts use Dict (tag "Dict") instead; the write-side routing in HDFArchiveGroup.__setitem__() selects the wrapper by key type.

Instances are created internally by HDFArchiveGroup and the class is registered with h5.formats.

Parameters:
obdict

The dict to wrap. Every key must be a scalar (str, bool, int, float or complex) or a tuple of such scalars.