Skip to content

Commit

Permalink
Consolidate listification of _package_versions.
Browse files Browse the repository at this point in the history
All uses but one of _package_versions want a list, and the last one
is not special in terms of memory footprint: just return a list from
_package_versions.
  • Loading branch information
rbtcollins committed Apr 20, 2015
1 parent e1c31f5 commit 3070609
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions pip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ def _find_all_versions(self, project_name):
project_name.lower(),
pkg_resources.safe_name(project_name.lower()).lower(),
frozenset(formats)
find_links_versions = list(self._package_versions(
find_links_versions = self._package_versions(
# We trust every directly linked archive in find_links
(Link(url, '-f', trusted=True) for url in self.find_links),
search
))
)

page_versions = []
for page in self._get_pages(url_locations, project_name):
Expand All @@ -434,9 +434,9 @@ def _find_all_versions(self, project_name):
self._package_versions(page.links, search)
)

dependency_versions = list(self._package_versions(
dependency_versions = self._package_versions(
(Link(url) for url in self.dependency_links), search
))
)
if dependency_versions:
logger.debug(
'dependency_links found: %s',
Expand All @@ -445,9 +445,7 @@ def _find_all_versions(self, project_name):
])
)

file_versions = list(
self._package_versions(file_locations, search)
)
file_versions = self._package_versions(file_locations, search)
if file_versions:
file_versions.sort(reverse=True)
logger.debug(
Expand Down Expand Up @@ -669,10 +667,9 @@ def _sort_links(self, links):
return no_eggs + eggs

def _package_versions(self, links, search):
for link in self._sort_links(links):
v = self._link_package_versions(link, search)
if v is not None:
yield v
vs = [self._link_package_versions(link, search)
for link in self._sort_links(links)]
return [v for v in vs if v is not None]

def _log_skipped_link(self, link, reason):
if link not in self.logged_links:
Expand Down

0 comments on commit 3070609

Please sign in to comment.