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.6.tar.gz (79.7 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.6-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lispython-0.4.6.tar.gz
  • Upload date:
  • Size: 79.7 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.6.tar.gz
Algorithm Hash digest
SHA256 4353fd1a9ce17eaa6b3d0de1ba0235429159eae846b2f97a66e2ae8427dca3a3
MD5 4a29bd5b448f3eaad3e674f77b4e90ba
BLAKE2b-256 33ef2da29e69af227219e82cd08ec5e04ce596623d6e8f1b40a31c809073dd66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lispython-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 37.3 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2763199930ae0a8058cde4fb5171b0601903eee18004e637ce3a70de8e66c434
MD5 b50a174eef4b187236b5f9a1751e8f4d
BLAKE2b-256 1a209b16f37d5cfb1f09ac34e30ce358cd370f158db79b662d3c4d2a24bc6dd6

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