Skip to content

Commit

Permalink
Make make_tupledict faster
Browse files Browse the repository at this point in the history
  • Loading branch information
metab0t committed Jun 27, 2024
1 parent 177ffd2 commit febd996
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pyoptinterface/_src/tupledict.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def flatten_tuple(t):


def make_tupledict(*coords: Iterable, rule):
kvs = []
d = {}
assert len(coords) > 0
for coord in product(*coords):
# (1, (2, 3), (4, 5)) -> (1, 2, 3, 4, 5)
Expand All @@ -128,5 +128,5 @@ def make_tupledict(*coords: Iterable, rule):
if len(coord) == 1:
coord = coord[0]
if value is not None:
kvs.append((coord, value))
return tupledict(kvs)
d[coord] = value
return tupledict(d)

0 comments on commit febd996

Please sign in to comment.