mirror of https://github.com/pypa/pip
compress the link parsing
This commit is contained in:
parent
1dd5f4fa5e
commit
9ab73d3bf7
|
@ -2,6 +2,7 @@
|
|||
|
||||
import enum
|
||||
import functools
|
||||
import gzip
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
|
@ -935,7 +936,7 @@ class PackageFinder:
|
|||
def _try_load_parsed_links_cache(parsed_links_path: Path) -> Optional[List[Link]]:
|
||||
page_links: Optional[List[Link]] = None
|
||||
try:
|
||||
with parsed_links_path.open("r") as f:
|
||||
with gzip.open(parsed_links_path, mode="rt", encoding="utf-8") as f:
|
||||
logger.debug("reading page links from cache %s", parsed_links_path)
|
||||
cached_links = json.load(f)
|
||||
page_links = []
|
||||
|
@ -967,7 +968,7 @@ class PackageFinder:
|
|||
page_links.append(link)
|
||||
|
||||
logger.debug("writing page links to %s", parsed_links_path)
|
||||
with parsed_links_path.open("w") as f:
|
||||
with gzip.open(parsed_links_path, mode="wt", encoding="utf-8") as f:
|
||||
json.dump(cacheable_links, f)
|
||||
|
||||
return page_links
|
||||
|
@ -977,7 +978,7 @@ class PackageFinder:
|
|||
cached_candidates_path: Path,
|
||||
) -> Optional[List[InstallationCandidate]]:
|
||||
try:
|
||||
with cached_candidates_path.open("r") as f:
|
||||
with gzip.open(cached_candidates_path, mode="rt", encoding="utf-8") as f:
|
||||
serialized_candidates = json.load(f)
|
||||
logger.debug("read serialized candidates from %s", cached_candidates_path)
|
||||
package_links: List[InstallationCandidate] = []
|
||||
|
@ -1011,7 +1012,7 @@ class PackageFinder:
|
|||
)
|
||||
for candidate in candidates
|
||||
]
|
||||
with cached_candidates_path.open("w") as f:
|
||||
with gzip.open(cached_candidates_path, mode="wt", encoding="utf-8") as f:
|
||||
logger.debug("writing serialized candidates to %s", f.name)
|
||||
json.dump(serialized_candidates, f)
|
||||
return candidates
|
||||
|
|
Loading…
Reference in New Issue