From 0139aac7d64247ba2fbe26b8bd6013e56d97f840 Mon Sep 17 00:00:00 2001 From: p1c2u Date: Sat, 16 May 2026 23:24:40 +0100 Subject: [PATCH] AccessorPath accessor-aware equality --- pathable/paths.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pathable/paths.py b/pathable/paths.py index 39b61ce..6bf246b 100644 --- a/pathable/paths.py +++ b/pathable/paths.py @@ -391,6 +391,17 @@ def _clone_with_parts( accessor=self.accessor, ) + def _identity_key(self) -> tuple[str, tuple[K, ...], int]: + return (self.separator, self.parts, id(self.accessor)) + + def __hash__(self) -> int: + return hash(self._identity_key()) + + def __eq__(self, other: Any) -> bool: + if not isinstance(other, AccessorPath): + return NotImplemented + return self._identity_key() == other._identity_key() + def __rtruediv__(self: TAccessorPath, key: Hashable) -> TAccessorPath: try: return self._from_parts(