h5.archive.DictNonStrKey
- class h5.archive.DictNonStrKey(ob)[source]
Archive wrapper for a Python
dictwith non-string keys.Stored in the same layout as a C++
std::mapwith non-string keys (format tag"DictNonStrKey"): each(key, value)pair is written into a numbered subgroup holding akeyand aval. The key is stored raw – a scalar key as a scalar dataset, a tuple key as aTuplesubgroup – so a dict with homogeneous keys is byte-compatible with the corresponding C++std::map<Key, T>(an int-keyed dict withstd::map<long, T>, a pair-keyed dict withstd::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::mapcounterpart. String-keyed dicts useDict(tag"Dict") instead; the write-side routing inHDFArchiveGroup.__setitem__()selects the wrapper by key type.Instances are created internally by
HDFArchiveGroupand the class is registered withh5.formats.- Parameters:
- obdict
The dict to wrap. Every key must be a scalar (
str,bool,int,floatorcomplex) or a tuple of such scalars.