This release is a pre-release and may not be stable for production use.
Lispyn — Lisp-powered AI notebooks
Lispyn is a macro-first toolkit for authoring AI experiments in Hy (Lisp for Python). Define and compose reusable compile-time macros, then run your experiments directly or compile them into ordinary Python Jupyter notebooks.
The core product is a language of Hy macros, not a replacement for PyTorch, NumPy, pandas, Matplotlib or Python. Macro expansion makes experiment structure explicit and inspectable; small Python helpers handle numerical operations where appropriate. Your models, data, optimizers and evaluation logic remain native Python.
Why use Lispyn for AI notebooks?
Macros are the main abstraction. Hy macros transform source code at compilation, rather than just exposing another training API. Compose native Python operations, build reusable training functions, and create your own macros. Version 0.39 introduces deftrain-step, optimizer-step, collect-epochs, with-training, with-grad and with-rng-fork — six self-contained macros that expand into Python without a new Lispyn runtime backend.
(require lispyn.macros [deftrain-step collect-epochs])
(deftrain-step train-one model optimizer criterion)
(setv history (collect-epochs epoch 4
(train-one features labels)))
See the runnable CPU macro-first example and the guide to developing your own macros, including hygienic names, composition, independent notebook cells and compile-time security.
One source, three artifacts. Write a .hy experiment once. Run it as a script (run), compile an unexecuted notebook (build), or execute it and save real outputs (execute). The resulting notebook contains ordinary Python, not an opaque Lispyn engine.
Data splitting and explicit checks. The real PyTorch quickstart splits data into training, validation and held-out test sets:
(setv [training validation held-out]
(train-val-test dataset :validation-fraction 0.25
:test-fraction 0.25 :seed seed))
The input validation example rejects bad shapes and nonfinite numbers:
(require lispyn.macros [assert-finite assert-shape])
(import numpy :as np)
(import pandas :as pd)
(setv features (np.array [[1.0 2.0] [3.0 4.0]]))
(assert-shape features [2 2] :name "features")
(assert-finite features :name "features")
Check classification class balance with the runnable example:
(require lispyn.macros [label-balance plot-label-balance])
(setv labels ["cat" "cat" "cat" "dog" "dog" "bird"])
(setv report (label-balance labels :title "Training label distribution"))
For classification, class-weights computes inverse-frequency loss weights, and threshold-report compares validation probability cutoffs without peeking at held-out test labels.
Native PyTorch, not a parallel framework. Use macros such as with-eval, with-training, with-autocast, clip-gradients, with-parameter-freeze, gradient-report and predict-batches to generate inspectable operations or invoke explicit low-level checks. Training, autograd, optimizers, and saved checkpoints remain standard PyTorch. The PyTorch controls and diagnostics example run on the CPU.
Evidence-driven notebooks. The quickstart reports real PyTorch metrics:
(require lispyn.macros [report-run narrate metric-table])
(import lispyn.training [evaluate-metrics])
(report-run run :title "PyTorch baseline · recorded metrics")
Generate plots, comparisons, parameterized notebooks, and reports from run data. See the executed quickstart notebook.
Install
pip install lispyn
Python 3.10+ is required. The base package includes Hy, notebook compilation/execution, and Matplotlib. Install pandas with pip install "lispyn[data]". PyTorch is installed separately using the appropriate CPU or GPU build from PyTorch's installation guide. A cloned repository also offers the broader research environment:
pip install -r requirements.txt
Lispyn is experimental alpha software; macro interfaces may evolve.
Quickstart: run, build, execute
Clone the repository to access examples (the hello example does not require PyTorch):
git clone https://github.com/edujbarrios/lispyn.git
cd lispyn
1. Run a Hy experiment. Nothing is written to a notebook:
lispyn run examples/hello.hy
2. Build a shareable notebook. Nothing is executed; compilation creates ordinary Python and Markdown cells:
lispyn build examples/hello.hy -o hello.ipynb
3. Execute and capture outputs. Jupyter runs the compiled notebook and saves the executed cells:
lispyn execute examples/hello.hy -o hello-executed.ipynb
The hello example prints 2 + 3 + 5 = 10 and Lispyn checks passed!. For the full real experiment, try lispyn execute examples/quickstart.hy after installing torch. For macro-first CPU training, run lispyn execute examples/macro_first_training.hy. To inspect macro expansion directly, use hy2py examples/macro_first_training.hy.
Design principles and limits
Choose Lispyn when Lisp/Hy macros are worth the cognitive overhead, you want versioned experiments as source files, or you need reviewable standard-Python Jupyter artifacts. Use plain Python when interactive notebook editing is your main workflow or you do not need source transformations.
Macro-first means: focus on hygienic syntax transformations, scoped state management, and composable experiment code. It does not mean every numerical algorithm belongs inside a macro. Python backends are appropriate for substantial calculations and validations; macros provide the public authoring interface.
Security: Compile and execute only trusted Hy code. Hy macros can execute arbitrary Python at compile time, so even lispyn build is not sandboxed. Load checkpoints only from trusted sources. Lispyn cannot guarantee bitwise determinism, better accuracy, or absence of data leakage.
Documentation
Reference: 78 supported macros · Writing and extending macros · CPU macro-first walkthrough · Notebook gallery · Changelog · Citation
Created by Eduardo J. Barrios · Apache-2.0 licensed · experimental alpha software.
Metadata
Release files for lispyn 0.39.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lispyn-0.39.0a1.tar.gz | 166.9 kB | With provenance | Details for lispyn-0.39.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lispyn-0.39.0a1-py3-none-any.whl | Python 3 | none | any | Details for lispyn-0.39.0a1-py3-none-any.whl |
Total release size: 270.6 kB
Release files / lispyn-0.39.0a1.tar.gz
| Download URL | lispyn-0.39.0a1.tar.gz |
|---|---|
| Size | 166.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9628355aeb01f81e0c12225e25007dd3a63e116d0b67f0141bf699451844d2eb
|
|
BLAKE2b-256 checksum How to use checksums |
5460e30dc09d2024adde738026a49b8ee67d88e50a1f408df53325ceea760b9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 20, 2026.
Transparency logRelease files / lispyn-0.39.0a1-py3-none-any.whl
| Download URL | lispyn-0.39.0a1-py3-none-any.whl |
|---|---|
| Size | 103.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0748805eec067062fb70c8388c91b8052e10b6eed4325549c96d0f073246aad6
|
|
BLAKE2b-256 checksum How to use checksums |
870d05c73f5a15f06ed5c78c6eaa60cc901c0beeef3ee99f00ce49ccf1a2ded9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 20, 2026.
Transparency logSecurity for lispyn 0.39.0a1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lispyn-0.39.0a1.tar.gz
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 Nov 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.