diff --git a/python/lsst/daf/butler/core/dimensions/_coordinate.py b/python/lsst/daf/butler/core/dimensions/_coordinate.py index afe5985fe0..5bdc046b6e 100644 --- a/python/lsst/daf/butler/core/dimensions/_coordinate.py +++ b/python/lsst/daf/butler/core/dimensions/_coordinate.py @@ -527,6 +527,16 @@ def full(self) -> NamedKeyMapping[Dimension, DataIdValue]: assert self.hasFull(), "full may only be accessed if hasFull() returns True." return _DataCoordinateFullView(self) + @abstractmethod + def values_tuple(self) -> tuple[DataIdValue, ...]: + """Return the required values (only) of this data ID as a tuple. + + In contexts where all data IDs have the same dimensions, comparing and + hashing these tuples can be *much* faster than comparing the original + `DataCoordinate` instances. + """ + raise NotImplementedError() + @abstractmethod def hasRecords(self) -> bool: """Whether this data ID contains records. @@ -954,6 +964,10 @@ def hasRecords(self) -> bool: # Docstring inherited from DataCoordinate. return False + def values_tuple(self) -> tuple[DataIdValue, ...]: + # Docstring inherited from DataCoordinate. + return self._values[: len(self._graph.required)] + def _record(self, name: str) -> DimensionRecord | None: # Docstring inherited from DataCoordinate. raise AssertionError()