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-trip —
decode(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
Metadata
Release files for pylits 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pylits-0.1.1.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pylits-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.6 kB
Release files / pylits-0.1.1.tar.gz
| Download URL | pylits-0.1.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43810e49336cb933022922810981bca7a1c46c71bb1a057140f0425c73e4d9f8
|
|
BLAKE2b-256 checksum How to use checksums |
2a38ab0e556bc3c5841042f0775acc1e9ff406469e5979f19d28047689910dba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / pylits-0.1.1-py3-none-any.whl
| Download URL | pylits-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b2313c12aba1b1de2d0640d2926f211db33401ae222c02987c515379461733b
|
|
BLAKE2b-256 checksum How to use checksums |
91d5b918b3508ba0abcc4c0e1d1f6c0b0222a8e245b715a3d8b4b530d17880a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|