Skip to main content

Modern high-performance serialization utilities for Python

Project description

srsly: Modern high-performance serialization utilities for Python

This package bundles some of the best Python serialization libraries into one standalone package, with a high-level API that makes it easy to write code that's correct across platforms and Pythons. This allows us to provide all the serialization utilities we need in a single binary wheel.

⚠️ Still under construction!

Travis Appveyor PyPi GitHub Python wheels

Motivation

Serialization is hard, especially across Python versions and multiple platforms. After dealing with many subtle bugs over the years (encodings, locales, large files) our libraries like spaCy and Prodigy have steadily grown a number of utility functions to wrap the multiple serialization formats we need to support (especially json, msgpack and pickle). These wrapping functions ended up duplicated across our codebases, so we wanted to put them in one place.

At the same time, we noticed that having a lot of small dependencies was making maintainence harder, and making installation slower. To solve this, we've made srsly standalone, by including the component packages directly within it. This way we can provide all the serialization utilities we need in a single binary wheel.

srsly currently includes forks of the following packages:

Installation

srsly can be installed from pip:

pip install srsly

Alternatively, you can also comile the library from source. You'll need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler (XCode command-line tools on macOS / OS X or Visual C++ build tools on Windows), pip, virtualenv and git installed.

pip install -r requirements.txt  # install development dependencies
python setup.py build_ext --inplace  # compile the library

API

function srsly.json_dumps

Serialize an object to a JSON string. Takes care of Python 2/3 compatibility and falls back to json if sort_keys=True is used (until it's fixed in ujson).

data = {"foo": "bar", "baz": 123}
json_string = srsly.json_dumps(data)
Argument Type Description
data - The JSON-serializable data to output.
indent int Number of spaces used to indent JSON. Defaults to 2.
sort_keys bool Sort dictionary keys. Defaults to False.
RETURNS unicode The serialized string.

function srsly.json_loads

Deserialize unicode or bytes to a Python object.

data = '{"foo": "bar", "baz": 123}'
obj = srsly.json_loads(data)
Argument Type Description
data unicode / bytes The data to deserialize.
RETURNS - The deserialized Python object.

function srsly.read_json

Load JSON from a file or standard input.

data = srsly.read_json("/path/to/file.json")
Argument Type Description
location unicode / Path The file path or "-" to read from stdin.
RETURNS dict / list The loaded JSON content.

function srsly.write_json

Create a JSON file and dump contents or write to standard output.

data = {"foo": "bar", "baz": 123}
srsly.write_json("/path/to/file.jsonl", data)
Argument Type Description
location unicode / Path The file path or "-" to write to stdout.
data - The JSON-serializable data to output.
indent int Number of spaces used to indent JSON. Defaults to 2.

function srsly.read_jsonl

Read a JSONL file (newline-delimited JSON) or from JSONL data from standard input and yield contents line by line. Blank lines will always be skipped.

data = srsly.read_jsonl("/path/to/file.jsonl")
Argument Type Description
location unicode / Path The file path or "-" to read from stdin.
skip bool Skip broken lines and don't raise ValueError. Defaults to False.
YIELDS - The loaded JSON contents of each line.

function srsly.write_jsonl

Create a JSONL file (newline-delimited JSON) and dump contents line by line, or write to standard output.

data = [{"foo": "bar"}, {"baz": 123}]
srsly.write_jsonl("/path/to/file.jsonl", data)
Argument Type Description
location unicode / Path The file path or "-" to write to stdout.
lines iterable The JSON-serializable lines.

function srsly.is_json_serializable

Check if a Python object is JSON-serializable.

assert srsly.is_json_serializable({"hello": "world"}) is True
assert srsly.is_json_serializable(lambda x: x) is False
Argument Type Description
obj - The object to check.
RETURNS bool Whether the object is JSON-serializable.

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

srsly-0.0.3.tar.gz (183.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

srsly-0.0.3-cp37-cp37m-win_amd64.whl (167.4 kB view details)

Uploaded CPython 3.7mWindows x86-64

srsly-0.0.3-cp37-cp37m-manylinux1_x86_64.whl (177.2 kB view details)

Uploaded CPython 3.7m

srsly-0.0.3-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (267.5 kB view details)

Uploaded CPython 3.7mmacOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.6+ Intel (x86-64, i386)macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

srsly-0.0.3-cp36-cp36m-win_amd64.whl (167.9 kB view details)

Uploaded CPython 3.6mWindows x86-64

srsly-0.0.3-cp36-cp36m-manylinux1_x86_64.whl (177.2 kB view details)

Uploaded CPython 3.6m

srsly-0.0.3-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (270.6 kB view details)

Uploaded CPython 3.6mmacOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.6+ Intel (x86-64, i386)macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

srsly-0.0.3-cp35-cp35m-win_amd64.whl (166.3 kB view details)

Uploaded CPython 3.5mWindows x86-64

srsly-0.0.3-cp35-cp35m-manylinux1_x86_64.whl (175.5 kB view details)

Uploaded CPython 3.5m

srsly-0.0.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (264.2 kB view details)

Uploaded CPython 3.5mmacOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.6+ Intel (x86-64, i386)macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

srsly-0.0.3-cp27-cp27mu-manylinux1_x86_64.whl (171.8 kB view details)

Uploaded CPython 2.7mu

srsly-0.0.3-cp27-cp27m-win_amd64.whl (159.8 kB view details)

Uploaded CPython 2.7mWindows x86-64

srsly-0.0.3-cp27-cp27m-manylinux1_x86_64.whl (171.8 kB view details)

Uploaded CPython 2.7m

srsly-0.0.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (263.3 kB view details)

Uploaded CPython 2.7mmacOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.6+ Intel (x86-64, i386)macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

File details

Details for the file srsly-0.0.3.tar.gz.

File metadata

  • Download URL: srsly-0.0.3.tar.gz
  • Upload date:
  • Size: 183.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3048ac6861606b417f6602933519dcbdbc990f4d791a224914bb760ec14671ff
MD5 905c6a42d9f1a5471ac3b5596c47b089
BLAKE2b-256 d5ae032be119bf7b2af30a4ada9b2134a109942e1fe2974137c7cff261a6c20f

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 167.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 644d837226d2ff7ac2e720eae071d4d056264ba745b03c162712ef7ab59de0ab
MD5 f314eedf71443f9d3178688ec2a65390
BLAKE2b-256 fe25ed4d535409ba58aeb0f221920cff018129f2243d9e1cbeb2e7ce30c4ffc7

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 177.2 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3e22ba47448a2b6c89e9db9663cd1ff66f9b35d728a6bf4de3642ae70cb5076b
MD5 6153ca5787a3169414ac5e6951f0b2fe
BLAKE2b-256 431600bda3d6dcc6fca5140ccf24777c1ed8f18081f2ef96ec4131e4657a861c

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for srsly-0.0.3-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 22bddc5a052d6f01523549f7ba77ed50e2ea97c526d2a161774554801cd16994
MD5 8a570548d912c92ab5d77ac598c2be91
BLAKE2b-256 ae7a628cac12319045129e65e959aa83ef41b82a593d8200e834aba894e7d8a3

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 167.9 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 da43deeb00e3033f5a105dbb1c30f1d616c12fb5d4a309c04e49d43a0b1221c1
MD5 ea1d0641859596602b86edb510cc6732
BLAKE2b-256 21ea93d7256e6bd8d3ce86869dbf7babeafa4a7d30a6678f4e9d0550c83cc536

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 177.2 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 50e573228bef9b31fafc1706f7b83f01fdd1b71ff747664e3a8f66123b50cc62
MD5 2aeb8055320cb7b65930da765012828d
BLAKE2b-256 7789832c193f3d3b06f2b001ad0e5913c64f63f56150e398da4b583c15426591

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for srsly-0.0.3-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 731b8c40ba1f6d36885f27bc342901fa095a2aa2e60e4f10e1c10ac6b38d96a4
MD5 078c1c75ab472a7bb11e434d65a84959
BLAKE2b-256 5ad5e37dd28bfafb610dcf8e65bcaa704958c620c442c27a057b9664c18c26f5

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 166.3 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 b1397f82869034955eb49511791c652ab8e7b6357f52677acf538dba74f31c5c
MD5 fa55e9338bd0d465f10d25ba31f87ed5
BLAKE2b-256 ee3b4bed19e6776449b8303c00a6c4614e545fd519db027e407051906f5cddd9

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 175.5 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0088f14565b71000548a76cb90587d04a504e35a73626612af1fe560b662ace5
MD5 ee90299e7b90e5b8797487236eee5f74
BLAKE2b-256 300fda9453e9800fee99b030a9aad8cf9b0d4d963a28345d34ea81b87edcb9cc

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for srsly-0.0.3-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 a0d16b12c129e7314b22ebce7bc4eed76d7705cf888a8e08e31204f2822f0d61
MD5 232ad4e75ebf891718fbb43bd7eb3735
BLAKE2b-256 cb870bdda768efec108cfd7529cc5f39de3f8f42fdd2b9fe440e4382fb166707

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 171.8 kB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a14c86b903549bd0971ecbb1d0a76dc5a1e84ce5d9e6237d471dbee6bbfc8d3d
MD5 bb227cea339304ac74e5327a38bf200f
BLAKE2b-256 d1cbfb5eb599d46f294fde875f1da710f09ccc4d69c853e014fc4fb1298ee75d

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 159.8 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 6700c4721a661a7bb3aa9a7fc59877bfd8270e96ebabc9c743a87d7cbbcf4d7f
MD5 2903b67b811d1a13771e6b62d601d20f
BLAKE2b-256 531811c22ff1679c5ef1214319ca2decb6d47e494e19ce88950ea6b2a2eac809

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: srsly-0.0.3-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 171.8 kB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for srsly-0.0.3-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 50fbe0b09f2e42e10e73b5ddb1c17e5ec1a33b02975804eef90689a65b4942e7
MD5 25732932f322626c0c0db022f5f7a9ef
BLAKE2b-256 b9ee61754bfd1929fa4c68b2fa073b0898a11c634af93530a82e43c5c2d51619

See more details on using hashes here.

File details

Details for the file srsly-0.0.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for srsly-0.0.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 47c297d830a16b8a895c1c2c1191c4ef6c99db0366d5d5bc820531d71da1909e
MD5 d78c975af525311fdf79c6d65db392df
BLAKE2b-256 dbd4ea0178c355225a4ad2679f24c318e06205549e43ebc10f7c1a5fa4442646

See more details on using hashes here.

Supported by

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