Python source code as a serialization format with automatic import resolution
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycodify-0.1.3.tar.gz.
File metadata
- Download URL: pycodify-0.1.3.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e591da6f904065a7b98312c942fad2d1bc0577bf202b2c8715379544fc8c8e7
|
|
| MD5 |
e6e7fbead931456f653a1af509909cfc
|
|
| BLAKE2b-256 |
cd022f7e8467befb466c5e271227d6764b0a5ad775d60ee5ea8f09ccc6c192b2
|
Provenance
The following attestation bundles were made for pycodify-0.1.3.tar.gz:
Publisher:
publish.yml on OpenHCSDev/pycodify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycodify-0.1.3.tar.gz -
Subject digest:
9e591da6f904065a7b98312c942fad2d1bc0577bf202b2c8715379544fc8c8e7 - Sigstore transparency entry: 2214812331
- Sigstore integration time:
-
Permalink:
OpenHCSDev/pycodify@792b03413331fdf107e369c924c257a2f0b16126 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/OpenHCSDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@792b03413331fdf107e369c924c257a2f0b16126 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycodify-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pycodify-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f855880a67bd65c7f5d0d33d07486318367cb082df37c42e1037b66c3516142
|
|
| MD5 |
26379b5893059e7512d078c95c8c3120
|
|
| BLAKE2b-256 |
42dd741619c2334766bbed55b6860ecbd54849cd28452c45b14d6c05a41ef21c
|
Provenance
The following attestation bundles were made for pycodify-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on OpenHCSDev/pycodify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycodify-0.1.3-py3-none-any.whl -
Subject digest:
7f855880a67bd65c7f5d0d33d07486318367cb082df37c42e1037b66c3516142 - Sigstore transparency entry: 2214812365
- Sigstore integration time:
-
Permalink:
OpenHCSDev/pycodify@792b03413331fdf107e369c924c257a2f0b16126 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/OpenHCSDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@792b03413331fdf107e369c924c257a2f0b16126 -
Trigger Event:
push
-
Statement type: