From 60f29b0b2f5298efff43e5155f6f9792ba4e0ccf Mon Sep 17 00:00:00 2001 From: Deepak Mallubhotla Date: Sat, 11 May 2024 20:49:26 -0500 Subject: [PATCH] perf: avoid recalculating product dict in indexifier to improve performance for probs --- deepdog/indexify/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepdog/indexify/__init__.py b/deepdog/indexify/__init__.py index 807a933..4cad9d6 100644 --- a/deepdog/indexify/__init__.py +++ b/deepdog/indexify/__init__.py @@ -31,10 +31,10 @@ class Indexifier: def __init__(self, list_dict: typing.Dict[str, typing.Sequence]): self.dict = list_dict + self.product_dict = _dict_product(self.dict) def indexify(self, n: int) -> typing.Dict[str, typing.Any]: - product_dict = _dict_product(self.dict) - return product_dict[n] + return self.product_dict[n] def _indexify_indices(self, n: int) -> typing.Sequence[int]: """