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

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.1.3
File Size Uploaded
pycodify-0.1.3.tar.gz 23.5 kB Details

Built distribution (wheel)

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

Total release size: 31.7 kB

Release files / pycodify-0.1.3.tar.gz

Download URL pycodify-0.1.3.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e591da6f904065a7b98312c942fad2d1bc0577bf202b2c8715379544fc8c8e7
BLAKE2b-256 checksum
How to use checksums
cd022f7e8467befb466c5e271227d6764b0a5ad775d60ee5ea8f09ccc6c192b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 21, 2026.

Transparency log

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

Download URL pycodify-0.1.3-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f855880a67bd65c7f5d0d33d07486318367cb082df37c42e1037b66c3516142
BLAKE2b-256 checksum
How to use checksums
42dd741619c2334766bbed55b6860ecbd54849cd28452c45b14d6c05a41ef21c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

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