Skip to content

Commit

Permalink
Use only one resolver in functional API
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sirosen committed Nov 1, 2024
1 parent 1c99d4a commit eac62d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
Unreleased
----------

- Optimize the behavior of the ``resolve()`` function on multiple groups.

1.3.0
-----

Expand Down
7 changes: 2 additions & 5 deletions src/dependency_groups/_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,5 @@ def resolve(
:raises LookupError: if group name is absent
:raises packaging.requirements.InvalidRequirement: if a specifier is not valid
"""
return tuple(
str(r)
for group in groups
for r in DependencyGroupResolver(dependency_groups).resolve(group)
)
resolver = DependencyGroupResolver(dependency_groups)
return tuple(str(r) for group in groups for r in resolver.resolve(group))

0 comments on commit eac62d7

Please sign in to comment.