Skip to content

Commit 3605bb1

Browse files
committed
fix: add cache for _get_hops
1 parent 7239514 commit 3605bb1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pyrdf2vec/graphs/kg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ def _fill_hops(self, entities: Entities) -> None:
406406
hops = self._res2hops(Vertex(entity), res)
407407
self._entity_hops.update({entity: hops})
408408

409+
@cachedmethod(
410+
operator.attrgetter("cache"), key=partial(hashkey, "_get_hops")
411+
)
409412
def _get_hops(self, vertex: Vertex, is_reverse: bool = False) -> List[Hop]:
410413
"""Returns the hops of a vertex for a local Knowledge Graph.
411414

0 commit comments

Comments
 (0)