Closing attributes, etc.



I was curious if there were plans to add the ability to close an attribute/type/space. Maybe via a “close” method or upon object delete? For instance, H5Aclose, H5Sclose, H5Tclose are currently only used in the .pyx source code but are not available in the low-level API. For files with large amounts of objects with attributes, keeping all attributes/spaces/types open may accumulate a memory footprint over time.



Hi Zac,

h5py aims to bridge Python & HDF5’s reference counting, so when a Python object goes out of scope (e.g. local variables in a function that’s finished), its HDF5 ID is also cleaned up. You shouldn’t normally need to do any explicit cleanup of these objects.

If you do need it for some reason, objects in h5py’s low-level API, like AttrID, SpaceID, etc. all have a .close() method. This actually calls H5Idec_ref rather than one of the H5*close C functions, but that should do the same thing.