Skip to main content

Serialize and store Python literals with ease!

Project description

PyLits Logo

Pylits

pylits is a high-performance, deterministic serialization format for pure Python literals.

It provides extremely fast and reliable encoding/decoding while intentionally supporting only safe literal types, making it suitable for:

  • Storing data in files (safely than eval())
  • Transforming your DB into dynamic typed structures with support for lists and dictionaries
  • Hashing

Key Features

  • Very fast — minimal parsing overhead compared to JSON-like formats
  • 🔒 Safe by design — supports only pure Python literals
  • 🎯 Deterministic — identical data always produces identical encoded output
  • 🧩 Zero dependencies — pure Python implementation
  • 🔁 Lossless round-tripdecode(encode(x)) == x

Supported Types

pylits works strictly with Python literal structures:

SupportedTypes = (
    bool
    | int
    | float
    | str
    | list["SupportedTypes"]
    | tuple["SupportedTypes", ...]
    | set["SupportedTypes"]
    | dict["SupportedTypes", "SupportedTypes"]
    | None
)

Anything outside this set is intentionally not supported.

Installation

pip install pylits

Quick Start

import pylits

data = [1, "2", True, (None, {"Pylits": 21})]

encoded = pylits.encode(data)
decoded = pylits.decode(encoded)

assert decoded == data

Examples

Lists

pylits.encode([1, "2"])
# "2l1i11s2"

pylits.decode("2l1i11s2")
# [1, "2"]

Strings

pylits.encode(["A", "AB", "ABC", "ABCD"])
# "4l1sA2sAB3sABC4sABCD"

Booleans

pylits.encode([True, False])
# "2l1bT1bF"

Deterministic Encoding

A modified internal encoder guarantees stable output even when:

  • dictionary key order differs
  • set element order differs

This makes pylits suitable for hashing.

License

MIT License
Copyright (c) 2026 Romashka


Changes in version 0.1.1

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

pylits-0.1.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

pylits-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pylits-0.1.1.tar.gz.

File metadata

  • Download URL: pylits-0.1.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pylits-0.1.1.tar.gz
Algorithm Hash digest
SHA256 43810e49336cb933022922810981bca7a1c46c71bb1a057140f0425c73e4d9f8
MD5 69524d557018b67098dc95805cc0fe40
BLAKE2b-256 2a38ab0e556bc3c5841042f0775acc1e9ff406469e5979f19d28047689910dba

See more details on using hashes here.

File details

Details for the file pylits-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pylits-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pylits-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b2313c12aba1b1de2d0640d2926f211db33401ae222c02987c515379461733b
MD5 67e122be46c138a481b8d8641c4894ee
BLAKE2b-256 91d5b918b3508ba0abcc4c0e1d1f6c0b0222a8e245b715a3d8b4b530d17880a5

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