Skip to content

Commit

Permalink
cache some Term methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Mar 20, 2022
1 parent 52ebb03 commit ac1bce2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/poetry/mixology/term.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import functools

from typing import TYPE_CHECKING

from poetry.mixology.set_relation import SetRelation
Expand Down Expand Up @@ -46,6 +48,7 @@ def satisfies(self, other: Term) -> bool:
and self.relation(other) == SetRelation.SUBSET
)

@functools.lru_cache(maxsize=None)
def relation(self, other: Term) -> int:
"""
Returns the relationship between the package versions
Expand Down Expand Up @@ -108,6 +111,7 @@ def relation(self, other: Term) -> int:
# not foo ^1.5.0 is a superset of not foo ^1.0.0
return SetRelation.OVERLAPPING

@functools.lru_cache(maxsize=None)
def intersect(self, other: Term) -> Term | None:
"""
Returns a Term that represents the packages
Expand Down

0 comments on commit ac1bce2

Please sign in to comment.