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.0

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.0.tar.gz (8.4 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.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylits-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 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.0.tar.gz
Algorithm Hash digest
SHA256 b98307f2c931e55ca2ca62cb00e4e47b6b6354b36254f751578d104b908460da
MD5 886fbe4a40ffcf45fac6ef84f3540b5d
BLAKE2b-256 40030d27f24ab4ef609628df095e65dba944f0946e1dee967a3e10c086216c2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylits-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a55871e36be0b312c0e090aef823bd657f5dd8e1243623c11b24afa511e109d
MD5 b4ae54dd0fb90e794724efcaf4ac9e88
BLAKE2b-256 54bbb4c1b7bf890ae035f92d517a9421ebbb8fca5529b42aa38a588b1d053aeb

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