Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ypyjson-0.0.2.tar.gz (160.9 kB view details)

Uploaded Source

Built Distribution

ypyjson-0.0.2-cp39-cp39-win_amd64.whl (226.2 kB view details)

Uploaded CPython 3.9 Windows x86-64

File details

Details for the file ypyjson-0.0.2.tar.gz.

File metadata

  • Download URL: ypyjson-0.0.2.tar.gz
  • Upload date:
  • Size: 160.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.7.1 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.13

File hashes

Hashes for ypyjson-0.0.2.tar.gz
Algorithm Hash digest
SHA256 656a70b10f91c9b79017f74029dde989ae71866e28ad9a7c77dd90744fb0cfdd
MD5 b8c76a685e489161e380640e66fa6c24
BLAKE2b-256 5ef90434ce5147eced6d3a6038fcd8039ff44f6eb5aee2cbf732b354c736e90b

See more details on using hashes here.

File details

Details for the file ypyjson-0.0.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ypyjson-0.0.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 226.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.7.1 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.13

File hashes

Hashes for ypyjson-0.0.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7468de90b03cc67f9a65655d46848d1b19ca2a7de10ccad578c50044c1690d9d
MD5 0d7cd13eaf10e6f80445a164d373b7f3
BLAKE2b-256 9bdc6485d4774e07b87cf1d7e60daa2dd97de35667c09f2333b40463f322d9da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page