Skip to main content

Custom Datetime JSON Serializer

Project description

CDJS (Custom Datetime JSON Serializer)

cdjs is an extension for orjson to serialize datetime in a custom way.

By default orjson serializes datetime according to RFC 3339 format which sometimes may not suit. orjson provides a mean to process datetime using custom serializer (via OPT_PASSTHROUGH_DATETIME flag and via default=custom_datetime_serializer). Serializers implemented in Python are usually not fast enough, that's the reason behind implementation of the custom datetime serializer written in Rust to gain optimal speed.

Example

import datetime
import orjson
from cdjs import serialize_date

mydate = datetime.datetime(2021, 1, 1, hour=0, minute=4, second=36, microsecond=123000)
orjson.dumps(mydate, option=orjson.OPT_PASSTHROUGH_DATETIME, default=serialize_date)

Benchmarks

TODO

Installation

pip install cdjs

Building

To make a develop build

python ./setup.py develop

To make a release build

Pre-requisites

# switch to nightly channel
RUSTUP_USE_CURL=1 rustup default nightly-2021-01-31
pip install maturin

To compile, package and publish to PyPI

maturin build --no-sdist --release --strip --manylinux off
maturin publish

Testing

To run tests

python -m unittest -v tests.test_serialization

Python Version Support

  • python 3.6

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

cdjs-0.1.3.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

cdjs-0.1.3-cp36-cp36m-manylinux2010_x86_64.whl (144.2 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

File details

Details for the file cdjs-0.1.3.tar.gz.

File metadata

  • Download URL: cdjs-0.1.3.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.9.4

File hashes

Hashes for cdjs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 070a0920ce50f54c7589d52f0fcc0798c766f5e8e78c3f06683ba228be8eec8d
MD5 39c135d7d7e7e7b0dd5304520daf4b73
BLAKE2b-256 de43292657850cc7605cbfd209cb8a90580a56907be3c52d4648eb8f7e489a37

See more details on using hashes here.

File details

Details for the file cdjs-0.1.3-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for cdjs-0.1.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 03e2fbb10a6be2cf50c162742956a1328892f59fcc980d60e622f33b45157da8
MD5 01ff6a5c1dab1fafbab2e84c1ec930e3
BLAKE2b-256 6b7684f5ab42b262645ca6cef5d91b72736d2a3fb07ae4e42555c734d6272c4a

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