-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ujson with orjson, add load and close for
jsonlcorpus
(#49)
* Update json to use orjson -> ujson -> json in this order * change core requirement from orjson to ujson * Fix use of json.load * Update jsonlcorpus to have a load/close methods * improve test to test for close and load, also fix how close() and load() work * Remove test cases (moved to tests), * remoe orjson_loaded flag * Fix use of json again * Update tests and add tests for comparing json and orjson * Remove usage of ujson * Finally fix usage of json with orjson * Final fix (hopefully) * Update tests
- Loading branch information
Showing
9 changed files
with
194 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from . import benchmark, beir, corpus | ||
from . import benchmark, beir, corpus, json_functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import json | ||
|
||
try: | ||
import orjson | ||
ORJSON_AVAILABLE = True | ||
except ImportError: | ||
ORJSON_AVAILABLE = False | ||
|
||
|
||
def dumps_with_builtin(d: dict) -> str: | ||
return json.dumps(d) | ||
|
||
def dumps_with_orjson(d: dict) -> str: | ||
return orjson.dumps(d).decode('utf-8') | ||
|
||
if ORJSON_AVAILABLE: | ||
dumps = dumps_with_orjson | ||
loads = orjson.loads | ||
else: | ||
dumps = dumps_with_builtin | ||
loads = json.loads | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.