Base object classes

Implements ObjectID base class and global object registry.

It used to be that we could store the HDF5 identifier in an ObjectID and simply close it when the object was deallocated. However, since HDF5 1.8.5 they have started recycling object identifiers, which breaks this system.

We now use a global registry of “proxy objects”. This is implemented via a weak-value dictionary which maps an integer representation of the identifier to an IDProxy object. There is only one IDProxy object in the universe for each integer identifier. Objects hold strong references to this “master” IDProxy object. As they are deallocated, the reference count of the IDProxy decreases. The use of a weak-value dictionary means that as soon as no ObjectIDs remain which reference the IDProxy, it is deallocated, closing the HDF5 integer identifier in its __dealloc__ method.

class h5py._objects.IDProxy
class h5py._objects.ObjectID

Represents an HDF5 identifier.

Previous topic

Low-level Reference

Next topic

Module H5

This Page