bagofholding.h5.triebag module

class bagofholding.h5.triebag.TrieH5Bag(filepath: str | Path, *args: object, **kwargs: Any)[source]

Bases: Bag, HasH5FileContext, ArrayPacker

A bag using HDF5 files based on h5py.

Uses a trie structure to flatten the stored object. Compared to bagofholding.h5.bag.H5Bag, this is advantageous for file sizes but (currently) has worse scaling for save times.

The resulting HDF5 file cannot be directly related to the structure of the stored object, but must be re-mapped via mapping fields. Metadata is also lumped in with other string data to minimize the number of different h5 groups.

create_group(path: str) None[source]
classmethod get_bag_info() BagInfo[source]
get_bespoke_content_class(obj: object) type[BespokeItem[Any, Self]] | None[source]
list_paths() list[str][source]

A list of all available content paths.

load(path: str = 'object', version_validator: Literal['exact', 'semantic-minor', 'semantic-major', 'none'] | Callable[[str, str], bool] = 'exact', version_scraping: dict[str, Callable[[str], str | None]] | None = None) Any[source]
open_group(path: str) set[str][source]
pack_array(obj: ndarray[tuple[int, ...], dtype[int8] | dtype[int16] | dtype[int32] | dtype[int64] | dtype[uint8] | dtype[uint16] | dtype[uint32] | dtype[uint64] | dtype[float16] | dtype[float32] | dtype[float64] | dtype[complex64] | dtype[complex128] | dtype[bool] | dtype[bytes_] | dtype[str_]], path: str) None[source]
pack_bool(obj: bool, path: str) None[source]
pack_bytearray(obj: bytearray, path: str) None[source]
pack_bytes(obj: bytes, path: str) None[source]
pack_complex(obj: complex, path: str) None[source]
pack_empty(path: str) None[source]
pack_float(obj: float, path: str) None[source]
pack_long(obj: int, path: str) None[source]
pack_string(obj: str, path: str) None[source]
unpack_array(path: str) ndarray[tuple[int, ...], dtype[int8] | dtype[int16] | dtype[int32] | dtype[int64] | dtype[uint8] | dtype[uint16] | dtype[uint32] | dtype[uint64] | dtype[float16] | dtype[float32] | dtype[float64] | dtype[complex64] | dtype[complex128] | dtype[bool] | dtype[bytes_] | dtype[str_]][source]
unpack_bool(path: str) bool[source]
unpack_bytearray(path: str) bytearray[source]
unpack_bytes(path: str) bytes[source]
unpack_complex(path: str) complex[source]
unpack_float(path: str) float[source]
unpack_long(path: str) int[source]
unpack_string(path: str) str[source]
property unpacked_trie: StringTrie