Closed matmill5 closed 3 years ago
Yeah, agreed.
Path segments (Line, QuadraticBezier, CubicBezier, and Arc) are very hashable.
E.g.
def __hash__(self):
hash(self.bpoints())
would work for bezier path segments (and __hash__
is already implemented similarly for Arc
objects).
The case of Path
itself is a bit more complicated if you want to include style or transform information that's not included in the Path.element
attribute (this can I think be the case when the path was part of an SVG-Group that was transformed). That said, I'd be open to pushing the solution:
def __hash__(self):
return hash((tuple(self._segments), self._closed))
I think the rest of the attributes included in your rough solution above are actually redundant (except Path.meta
which is too general-purpose to be hashable perhaps).
Would this work for your use case?
@matmill5 I pushed this solution to the hashable-paths branch.
If it doesn't work for your use case, then please let me know and we can adjust it before I merge it in.
@mathandy Thank you, I appreciate it, this looks like it will work for my use case.
Issue resolved - closing ticket.
It would be nice if Path objects were hashable.
Something like this:
Hashable Path