Skip to content

Commit 367b96e

Browse files
committed
in calculate_all_conversion_paths, use collections.deque for efficiency on large graphs
1 parent 7a075d1 commit 367b96e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

flixopt/effects.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import logging
1111
import warnings
12+
from collections import deque
1213
from collections.abc import Iterator
1314
from typing import TYPE_CHECKING, Literal
1415

@@ -570,10 +571,10 @@ def calculate_all_conversion_paths(
570571
# Keep track of visited paths to avoid repeating calculations
571572
processed_paths = set()
572573
# Use a queue with (current_domain, factor, path_history)
573-
queue = [(origin, 1, [origin])]
574+
queue = deque([(origin, 1, [origin])])
574575

575576
while queue:
576-
current_domain, factor, path = queue.pop(0)
577+
current_domain, factor, path = queue.popleft()
577578

578579
# Skip if we've processed this exact path before
579580
path_key = tuple(path)

0 commit comments

Comments
 (0)