Skip to content

Commit 823b743

Browse files
committed
upip: get_pkg_metadata: Use ujson.load() to save memory.
1 parent 3674457 commit 823b743

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

upip/upip.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ def url_open(url):
145145

146146
def get_pkg_metadata(name):
147147
f = url_open("https://pypi.python.org/pypi/%s/json" % name)
148-
s = f.read()
149-
f.close()
150-
return json.loads(s)
148+
try:
149+
return json.load(f)
150+
finally:
151+
f.close()
151152

152153

153154
def fatal(msg, exc=None):

0 commit comments

Comments
 (0)