Skip to content

Commit

Permalink
Use sets, which appear to be faster
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Aug 3, 2023
1 parent aa05cc1 commit 6d6ad89
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/globus_sdk/experimental/scope_parser/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ def _check_cycles(self) -> None:
# stack and pop from it until it is empty, thus implementing DFS
#
# conceptually, the paths could be implemented as `list[str]`, which would
# preserve the order in which we encountered each node. Using frozenset is a
# preserve the order in which we encountered each node. Using a set is a
# micro-optimization which makes checks faster, since we only care to detect
# *that* there was a cycle, not what the shape of that cycle was
paths_to_explore: list[tuple[frozenset[str], str]] = [
(frozenset((node,)), node) for node, _ in self.top_level_scopes
paths_to_explore: list[tuple[set[str], str]] = [
({node}, node) for node, _ in self.top_level_scopes
]

while paths_to_explore:
Expand Down

0 comments on commit 6d6ad89

Please sign in to comment.