Skip to content

Commit 1bc2959

Browse files
committed
cache some Term methods
1 parent 4f84905 commit 1bc2959

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/poetry/mixology/term.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import functools
4+
35
from typing import TYPE_CHECKING
46

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

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

114+
@functools.lru_cache(maxsize=None)
111115
def intersect(self, other: Term) -> Term | None:
112116
"""
113117
Returns a Term that represents the packages

0 commit comments

Comments
 (0)