Skip to content

Commit eac62d7

Browse files
committed
Use only one resolver in functional API
This is a small optimization. Rather than a resolver per group, there is only one resolver. As a result, resolutions done on one group are stored on the instance and available to subsequent resolution calls. More trivially, we save on some object instantiation overheads.
1 parent 1c99d4a commit eac62d7

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
Unreleased
55
----------
66

7+
- Optimize the behavior of the ``resolve()`` function on multiple groups.
8+
79
1.3.0
810
-----
911

src/dependency_groups/_implementation.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,5 @@ def resolve(
206206
:raises LookupError: if group name is absent
207207
:raises packaging.requirements.InvalidRequirement: if a specifier is not valid
208208
"""
209-
return tuple(
210-
str(r)
211-
for group in groups
212-
for r in DependencyGroupResolver(dependency_groups).resolve(group)
213-
)
209+
resolver = DependencyGroupResolver(dependency_groups)
210+
return tuple(str(r) for group in groups for r in resolver.resolve(group))

0 commit comments

Comments
 (0)