perf: avoid recalculating product dict in indexifier to improve performance for probs

This commit is contained in:
Deepak Mallubhotla 2024-05-11 20:49:26 -05:00
parent 093a3fb5c4
commit 60f29b0b2f
Signed by: deepak
GPG Key ID: BEBAEBF28083E022

View File

@ -31,10 +31,10 @@ class Indexifier:
def __init__(self, list_dict: typing.Dict[str, typing.Sequence]): def __init__(self, list_dict: typing.Dict[str, typing.Sequence]):
self.dict = list_dict self.dict = list_dict
self.product_dict = _dict_product(self.dict)
def indexify(self, n: int) -> typing.Dict[str, typing.Any]: def indexify(self, n: int) -> typing.Dict[str, typing.Any]:
product_dict = _dict_product(self.dict) return self.product_dict[n]
return product_dict[n]
def _indexify_indices(self, n: int) -> typing.Sequence[int]: def _indexify_indices(self, n: int) -> typing.Sequence[int]:
""" """