Skip to content

Commit

Permalink
Merge pull request #503 from danielhollas/defer-json
Browse files Browse the repository at this point in the history
Defer import of json
  • Loading branch information
jaraco authored Sep 11, 2024
2 parents 58832f2 + 2a3f50d commit 8b909f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import email
import functools
import itertools
import json
import operator
import os
import pathlib
Expand Down Expand Up @@ -673,6 +672,9 @@ def origin(self):
return self._load_json('direct_url.json')

def _load_json(self, filename):
# Deferred for performance (python/importlib_metadata#503)
import json

return pass_none(json.loads)(
self.read_text(filename),
object_hook=lambda data: types.SimpleNamespace(**data),
Expand Down
1 change: 1 addition & 0 deletions newsfragments/503.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deferred import of json

0 comments on commit 8b909f9

Please sign in to comment.