diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index 68737d86cc..0c9c58a203 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -61,7 +61,7 @@ This document explains the changes made to Iris for this release =========================== #. `@bouweandela`_ made loading :class:`~iris.cube.Cube`s from NetCDF files - faster. (:pull:`6229` and :pull:`6252`) + faster. (:pull:`6229`, :pull:`6252`, :pull:`6231`) #. `@fnattino`_ enabled lazy cube interpolation using the linear and nearest-neighbour interpolators (:class:`iris.analysis.Linear` and diff --git a/lib/iris/fileformats/netcdf/_thread_safe_nc.py b/lib/iris/fileformats/netcdf/_thread_safe_nc.py index 3a556f5447..9956f1480a 100644 --- a/lib/iris/fileformats/netcdf/_thread_safe_nc.py +++ b/lib/iris/fileformats/netcdf/_thread_safe_nc.py @@ -327,6 +327,12 @@ def ndim(self): def dask_meta(self): return np.ma.array(np.empty((0,) * self.ndim, dtype=self.dtype), mask=True) + def __dask_tokenize__(self): + # Dask uses this function to uniquely identify the "array". + # A custom function is slightly faster than general object tokenization, + # which improves the speed of loading small NetCDF files. + return f"<{self.__class__.__name__} path={self.path!r} variable_name={self.variable_name!r}>" + def __getitem__(self, keys): # Using a DatasetWrapper causes problems with invalid ID's and the # netCDF4 library, presumably because __getitem__ gets called so many