Python streamson
Python bindings for streamson. A memory efficient json splitter written in Rust. The project is still in an early phase, but it seems to be working
Installation
pip install streamson
Usage
Select users
>>> import streamson
>>> import json
>>> data = [b'{"users": ["john","carl","bob"], "groups": ["admins", "staff"], "org": "university"}']
>>> matcher = streamson.SimpleMatcher('{"users"}[]'])
>>> extracted = streamson.extract_iter((e for e in data), [(matcher, None)])
>>> for path, data in streamson.Output(extracted).generator():
... path, data
...
('{"users"}[0]', b'"john"')
('{"users"}[1]', b'"carl"')
('{"users"}[2]', b'"bob"')
Select users and groups
>>> import streamson
>>> import json
>>> data = [b'{"users": ["john","carl","bob"], "groups": ["admins", "staff"], "org": "university"}']
>>> matcher = streamson.SimpleMatcher('{"users"}[]']) | streamson.SimpleMatcher('{"groups"}[]'])
>>> extracted = streamson.extract_iter((e for e in data), [(matcher, None)])
>>> for path, data in streamson.Output(extracted):
... path, data
...
('{"users"}[0]', b'"john"')
('{"users"}[1]', b'"carl"')
('{"users"}[2]', b'"bob"')
('{"groups"}[0]', b'"admins"')
('{"groups"}[1]', b'"staff"')
Select only first level parts
>>> import streamson
>>> import json
>>> data = [b'{"users": ["john","carl","bob"], "groups": ["admins", "staff"], "org": "university"}']
>>> matcher = streamson.DepthMatcher(1, 1)
>>> extracted = streamson.extract_iter((e for e in data), [(matcher, None)])
>>> for path, data in streamson.Output(extracted):
... path, data
...
('{"users"}', b'["john", "carl", "bob"]')
('{"groups"}', b'["admins", "staff"]')
('{"org"}', b'"university"')
Select second first level parts exclude first records
>>> import streamson
>>> import json
>>> data = [b'{"users": ["john","carl","bob"], "groups": ["admins", "staff"], "org": "university"}']
>>> matcher = streamson.DepthMatcher(2, 2) & ~streamson.SimpleMatcher('{}[0]')
>>> extracted = streamson.extract_iter((e for e in data), [(matcher, None)])
>>> for path, data in streamson.Output(extracted):
... path, data
...
('{"users"}[1]', b'"carl"')
('{"users"}[2]', b'"bob"')
('{"groups"}[1]', b'"staff"')
Motivation
This project is meant to be use as a fast json splitter. Its main purpose is to split raw binary data instead of parsing it. It is supposed to be fast and memory efficient.
Developer Docs
Build
Poetry is used to manage python dev-dependencies. After you install it you can run:
poetry install
This project also requires the nighly version of Rust. First you need to install rustup.
rustup install nightly
And you might need to set it as a default toolchain.
rustup default nightly
Precommit deployment
To pass the basic lints you may want to install pre-push hook to pre-commit to be sure that CI won't fail in the first step.
poetry run pre-commit install -t pre-push
Metadata
Release files for streamson-python 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| streamson_python-4.0.0.tar.gz | 7.1 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| streamson_python-4.0.0-cp39-cp39-manylinux2010_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.12+ x86-64 | Details |
Total release size: 7.8 MB
Release files / streamson_python-4.0.0.tar.gz
| Download URL | streamson_python-4.0.0.tar.gz |
|---|---|
| Size | 7.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42561a6fe630554116e0525fdbf6f06411d79280b112172a550e3290e1f5efe3
|
|
BLAKE2b-256 checksum How to use checksums |
b94f827e579f7129378056be138071207ae96122767b3909317514fb3a64fbae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.9.4
|
Release files / streamson_python-4.0.0-cp39-cp39-manylinux2010_x86_64.whl
| Download URL | streamson_python-4.0.0-cp39-cp39-manylinux2010_x86_64.whl |
|---|---|
| Size | 749.8 kB |
| Tags | CPython 3.9 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
f22cfd41ea1f3c8710fcd301e3431dfd736df6113255c58f2ef1c56512f30062
|
|
BLAKE2b-256 checksum How to use checksums |
e7216b6342417fd5de503c436fc0c4e3ab67df8d732b98f4084a6f817b49e9fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/0.9.4
|
Security for streamson-python 4.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.