Skip to main content

Lisp-like Syntax for Python with Lisp-like Macros

Project description

LisPython

PyPI version

LisPython is a Lisp-flavored syntax for Python with Lisp-style macros. Source files (.lpy) are transpiled to Python and executed on the standard CPython runtime.

Documentation

Full documentation lives at https://jetack.github.io/lispython/.

Quick Start

(import math)

(def area [r]
  (return (* math.pi (** r 2))))

(print (area 3))
lpy example.lpy

Installation

Using pip

pip install lispython

Manual Installation (for development)

uv sync # install dependencies
uv pip install -e . # for development

How to Run LisPython code

Run from source

lpy {filename}.lpy

Run REPL

lpy
# or
lpy -t # if you want to print python translation.

Show translation

l2py {filename}.lpy

Prints the translated Python to stdout. It does not execute the code.

Run Tests

# in project root directory
pytest
# or
lpy -m pytest

LSP Server

LisPython ships with a language server (lpy-lsp) that speaks LSP over stdio. It provides:

  • Diagnostics (parse / compile errors)
  • Completions (special forms, builtins, file/workspace symbols)
  • Hover documentation for special forms and builtins
  • Document symbols
  • Go-to-definition, including across .lpy files in the workspace

nREPL Server

LisPython includes an nREPL server for REPL-driven development:

lpy --nrepl         # start on a random port
lpy --nrepl 7888    # start on a specific port

The server accepts newline-delimited JSON over TCP and supports:

  • eval — evaluate LisPython code, return value/stdout/error
  • load-file — load a .lpy file into the session
  • macroexpand — expand macros and return the result
  • complete — prefix and dot-completion from the live scope
  • docs — signature and docstring for a symbol
  • annotate — type tag (function/class/module/macro)

Editor setup

VS Code

Install the LisPython extension. It connects to both LSP and nREPL automatically.

Emacs

Use lpy-mode. It provides nREPL integration (eval, completion, eldoc, macroexpand) and LSP via eglot.

Todo

Python AST

  • type_comment never considered. Later, it should be covered
  • Any missing AST nodes in the version 3.12+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lispython-0.4.7.tar.gz (79.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lispython-0.4.7-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file lispython-0.4.7.tar.gz.

File metadata

  • Download URL: lispython-0.4.7.tar.gz
  • Upload date:
  • Size: 79.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lispython-0.4.7.tar.gz
Algorithm Hash digest
SHA256 39c05b7f0a64aee4e7082c080eb5873f82ec34e318bd296eb68006b19ce5b59a
MD5 30424d9397bd01b4c40e14a8850ec162
BLAKE2b-256 ef90ebc5fe291450cb2f9d3f7c59bab00522e13b2466f683add1e24eb1b497ea

See more details on using hashes here.

File details

Details for the file lispython-0.4.7-py3-none-any.whl.

File metadata

  • Download URL: lispython-0.4.7-py3-none-any.whl
  • Upload date:
  • Size: 37.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lispython-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7d32b78312d258d6e723c626d532e09ce25deb57bb0c27a0f35de537fd83f768
MD5 1073a29e144093b47f82c7dda5ffe362
BLAKE2b-256 35642efa2efb53f1b5627b64549545077a6708bb1d3773ffe18bf801f803ee5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page