yet another python json library using yyjson
Project description
YpyJson
Yet Another Python Json Library
A Fast Json Reader made in Cython for handling fast json parsing using the yyjson library.
Some of it's techniques are simillar to simdjson but with a few fast conversion methods to convert objects to python objects.
Ypyjson can trade safety for speed since yyjson is faster than simdjson
from ypyjson import YpyObject
y = YpyObject(b'{"Eggs":"spam","Foo":["bar","baz"]}', 0)
bar = y.get_pointer("/Foo/0")
print(f"result :{bar!r}")
# result: 'bar'
print(y["Eggs"])
# spam
Ypy also has flags for reading json files as well
from ypyjson import loads, YpyReadFlag
y = loads(b'{"ypy":"json","data":{"text":[1,2,3,4]}}', YpyReadFlag.ALLOW_COMMENTS | YpyReadFlag.READ_NUMBER_AS_RAW)
text = y.get_pointer("/data/text")
print(text)
for t in text:
print(t)
# <ypyjson.reader.YpyArray object at 0x00000256F6DD1D30>
# b'1'
# b'2'
# b'3'
# b'4'
Ypyjson has Cython compatability and is really made for Cython as well for expandable performance benefits elsewhere...
from ypyjson.reader cimport cloads, YpyObject , YpyArray
#etc...
Note that for the read flags, you'll need to refer to the Variable Documentation linked below in yyjson's documentation
https://ibireme.github.io/yyjson/doc/doxygen/html/yyjson_8h.html#aff1d62b68993630e74355e4611b77520
Luckily , ypyjson.reader.pxd
has them already inplace
so you'll just have to do the following
to access those variables...
#cython: langauge_level = 3
from ypyjson.reader cimport (
cloads,
YpyObject ,
YpyArray ,
YYJSON_READ_ALLOW_COMMENTS,
YYJSON_READ_ALLOW_INF_AND_NAN,
YYJSON_READ_ALLOW_INVALID_UNICODE
#etc...
)
Installation
For now it is still being worked on and figured out but I'm almost done so don't worry about it yet... :)
TODOs
-
Implement a reader and extract all variables directly to python...
-
[] Create Benchmarks with SimdJson's python library to figure what could be needed to improve this library's performance...
-
[] Make sure that after launching to pypi library for this code that YpyJson can work directly with Cython via cimport , Might have to look into numpy for ideas on it's implementation...
-
[] Maybe look into Adding YpyJson as a Header File for CPython Usage....
-
[] Make a YpyVariable cdef class Object in Cython (Cython only...) to improve upon speed until the Object needs or is ready to be identified in either C or Python...
-
[] In a future update, implement a mutable writer (The Current one made is broken and is having issues...)
-
[] When yyjson comes out with a Streaming API , add streaming API Under a DynamicLoader class varaible
-
[] Once Beta Version of this python library is avalibe and inplace via pypi Make sure that yyjson.c as well as yyjson.h is included for compiling to Cython.
-
including/bundling cython package with pypi when I've figure it out...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ypyjson-0.0.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a1efd0dec0e82bf61c3dec884c69016479ec8a57878229f6bb5902e24f9fd8d |
|
MD5 | f1873b0e4f89ce7ba0196fe663fc8bbb |
|
BLAKE2b-256 | 57f844e9dfbcc74c8b62500a36ceb06470b66e7bc0606551b0035b8175b9b195 |