Skip to main content

pycodify

Python source code as a serialization format with automatic import resolution.

Quick Start

from pycodify import Assignment, generate_python_source
from dataclasses import dataclass

@dataclass
class Config:
    name: str = "default"
    value: int = 42

config = Config(name="production", value=100)
code = generate_python_source(Assignment("config", config))
print(code)
# Output:
# from __main__ import Config
# config = Config(name='production', value=100)

Why Python Source?

Format Diffable Inspectable Editable Type-preserving Cross-version
pickle ✗ ✗ ✗ ✓ ✗
JSON/YAML ✓ ✓ ✓ ✗ ✓
Python source ✓ ✓ ✓ ✓ Depends on imported APIs

Binary formats like pickle cannot be diffed, inspected, or edited. Text formats like JSON lose type information. Python source is diffable, inspectable, editable, and type-preserving, but replay still depends on the imported APIs and constructor signatures remaining compatible.

Features

  • Complete Executable Source: Generates imports + code, not just expressions
  • Type-Preserving: Enums, Paths, callables serialize as themselves
  • Collision Handling: Automatic aliasing for name collisions across modules
  • Clean Mode: Omit fields matching defaults for concise output
  • Extensible: Register custom formatters for domain-specific types

Documentation

Explicit mode is the default (clean_mode=False), preserving every field for reproducibility. Pass clean_mode=True only when concise, default-eliding source is desired.

Generated output is executable Python, not a sandboxed data format. Review it before execution and never call exec on source generated from untrusted objects, custom formatters, headers, or edited files.

Full documentation available at pycodify.readthedocs.io

Installation

pip install pycodify

License

MIT

Metadata

Release files for pycodify 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycodify 0.2.0
File Size Uploaded
pycodify-0.2.0.tar.gz 28.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycodify 0.2.0
File Interpreter ABI Platform
pycodify-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.1 kB

Release files / pycodify-0.2.0.tar.gz

Download URL pycodify-0.2.0.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d5888d2282f309d49442dc1a5a6dcba0fc74317abf8c3cd1fa163955fead5f4c
BLAKE2b-256 checksum
How to use checksums
c12a7a844c46ca209b5b35a41d220d428bd5942c4008f807047b133f69d22fdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pycodify-0.2.0-py3-none-any.whl

Download URL pycodify-0.2.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5eef48dc9c0e47fa73b278b91b9b8697898fbb2492888f74478972feb02b307f
BLAKE2b-256 checksum
How to use checksums
2991bfeb15b077dd7b52d83d10e59aabac9ad785d392a82557881bc42243406f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page