Comments (2)
Pyjson5's parser does not preserve the comments or whitespaces. So the serializer is nearly identical to standard json.dump(s), except that pyjson5's output is HTML-safe and ASCII-only. If you need pretty printed data, then most likely you don't want either, because it hurts readability; and speed is also most likely quite unimportant, because it's not a lot of data to have to serialize. So I guess you could use pyjson5 for parsing, and json for stringifying.
from pyjson5.
I agree with sbant. Pretty printing is a desirable feature. After all, json5 emphasises on human friendliness, comments, etc. Using this parser a lot of it is lost.
However, the speed is amazing, nothing compares to it. And in some cases both are needed, e.g. real-time speed crucial app that needs to track config changes, which are potentially a manual user input.
dump(load(string)) == string, would be great to have as an option, even if a bit slower.
And another package is unbelievably slow.
Yaml is too slow, json is too raw, II was hoping to find a happy middle. Many are too complex, others at the risk of extinction, etc, etc... Difficult choice to be honest.
Benchmarked this package against a great lot and all looked great - happy middle, but this is a bit of a dealbreaker. For now, I will use abstracted orjson so I can swap later given I find a happy middle I was after. Maybe you know what sort of config parser sublime text
uses? That one looked perfect tbh.
Adding benchmarks for reference:
print(timeit.timeit('json.loads(json_text)', number=N, globals=globals()))
print(timeit.timeit('ujson.loads(json_text)', number=N, globals=globals()))
print(timeit.timeit('orjson.loads(json_text)', number=N, globals=globals()))
print(timeit.timeit('pyjson5.loads(json_text)', number=N, globals=globals()))
# print(timeit.timeit('yaml.load(json_text, Loader=Loader)', number=N, globals=globals()))
print(timeit.timeit('yaml.load(json_text, Loader=CLoader)', number=N, globals=globals()))
# 0.27317825198406354
# 0.12556396395666525
# 0.0474954119999893
# 0.12391428096452728
# 42.89380981097929
# 5.733772745996248
print(timeit.timeit('json.dumps(data)', number=N, globals=globals()))
print(timeit.timeit('ujson.dumps(data)', number=N, globals=globals()))
print(timeit.timeit('orjson.dumps(data).decode()', number=N, globals=globals()))
print(timeit.timeit('pyjson5.dumps(data)', number=N, globals=globals()))
# print(timeit.timeit('yaml.dump(data, Dumper=Dumper)', number=N, globals=globals()))
print(timeit.timeit('yaml.dump(data, Dumper=CDumper)', number=N, globals=globals()))
# 0.28529386199079454
# 0.10934980498859659
# 0.03539454500423744
# 0.1855485350242816
# 19.672126159013715
# 5.398652292031329
from pyjson5.
Related Issues (20)
- v1.4.9 - failed installation HOT 1
- Compile wheels for Windows HOT 1
- pyjson5 package fails to install on Apple M1 mini HOT 4
- Type hints HOT 2
- ImportError: cannot import name '__author__' from 'pyjson5.pyjson5' HOT 2
- Add Conda support HOT 2
- Support for custom object hook?
- 1.6.0: pep517 build fails HOT 7
- Installation difficulty on Windows starting v1.6.1 HOT 4
- Current Project status HOT 1
- Windows support HOT 2
- Decimal support?
- Pylance GeneralTypeIssue HOT 1
- supply_bytes=True in encode_* brings a headache to me HOT 3
- dumps: ValueError while escaping excessively long integers
- loads: OverflowError while decoding too big escaped Unicode character
- builds fails on raspberry pi 4 due to usage of __int128 HOT 1
- Replace `fast_double_parser` with `fast_float`
- Installation issue on MacOS - ARM chip HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyjson5.