Skip to content

Commit

Permalink
Avoid parsing dist.version twice in a row
Browse files Browse the repository at this point in the history
dist.version is a property that parses the version string each time, so it's slightly faster to only parse it once.
  • Loading branch information
collinanderson authored Apr 4, 2023
1 parent 81f6a9f commit fc29515
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/pip/_internal/operations/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ def freeze(


def _format_as_name_version(dist: BaseDistribution) -> str:
if isinstance(dist.version, Version):
return f"{dist.raw_name}=={dist.version}"
return f"{dist.raw_name}==={dist.version}"
dist_version = dist.version
if isinstance(dist_version, Version):
return f"{dist.raw_name}=={dist_version}"
return f"{dist.raw_name}==={dist_version}"


def _get_editable_info(dist: BaseDistribution) -> _EditableInfo:
Expand Down

0 comments on commit fc29515

Please sign in to comment.