snuggs
Snuggs are s-expressions for Numpy
What it is and what it does
Snuggs is a small expression evaluator that lets you write NumPy computations using Lisp-like s-expression syntax instead of Python. You pass a string like `(+ 1 2)` or `(mean (asarray 1 2 4))` to snuggs.eval(), and it parses and executes the expression, returning the result. It wraps NumPy functions and operators (arithmetic, logical, and higher-order functions like map and partial) in a functional, parenthesis-heavy syntax.
The main use case is writing simple, expression-based array calculations—particularly useful when you need to serialize computations as strings or accept user-provided formulas as input. It supports passing NumPy arrays as named context variables, so expressions can reference external data. The package is lightweight (only numpy and pyparsing as dependencies) and has no known security vulnerabilities, but performance is not optimized; the documentation explicitly notes it lacks the multithreading and temporary-elimination optimizations of libraries like numexpr.
Use it for:
- Accept user-provided mathematical expressions as strings and evaluate them against NumPy arrays without parsing Python code.
- Serialize array computations as s-expressions for storage, transmission, or later evaluation.
- Write simple calculator-style programs that combine NumPy functions with arithmetic and logical operators.
- Build domain-specific languages or configuration systems that need to express array transformations functionally.
- Prototype numerical algorithms using Lisp-like syntax before translating to optimized Python or compiled code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Snuggs evaluates s-expressions (Lisp-like syntax) that operate on NumPy arrays and scalars, letting you write array computations as nested function calls rather than Python code.
Yes, if you need to evaluate user-supplied or serialized array expressions safely and don't require high performance. The low install friction, permissive license, and lack of vulnerabilities make it a straightforward choice for expression-based workflows. Not recommended if you need optimized array computation; use numexpr or raw NumPy instead.
Install
snuggs on PyPI
pip
pip install snuggsuv
uv add snuggspoetry
poetry add snuggsInstalling snuggs
Before you install
Low install friction with only two runtime dependencies (numpy and pyparsing). The package is actively maintained with recent commits, though the latest release was in 2019.
License in practice
MIT license is permissive; you can use, modify, and distribute snuggs freely in commercial and private projects with minimal restrictions.
Quickstart
import snuggs
import numpy as np
# Simple arithmetic
snuggs.eval('(+ 1 2)')
# 3
# Array operations
snuggs.eval("(+ (asarray 1 1) (asarray 2 2))")
# array([3, 3])
# With context variables
snuggs.eval("(+ (asarray 1 1) b)", b=np.array([2, 2]))
# array([3, 3])
Verify before relying
- Whether the package is actively developed or maintained in maintenance mode only (last release 2019, but recent commits in 2026)
- Python version compatibility and support range (requires_python field is empty)
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — numpy, pyparsing |
| Maintenance | actively maintained — 2,522 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 560,186/month — #6,005 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: snuggs-1.4.7-py3-none-any.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
consImplements Lisp/Scheme-style cons operations…
unclear · top 5,000 on PyPI
sexpdataParses and serializes S-expressions (Lisp-style…
permissive · top 15,000 on PyPI
etuplesProvides S-expression emulation using…
permissive · top 5,000 on PyPI
pampyPampy provides pattern matching for Python,…
permissive · top 15,000 on PyPI
numexprNumExpr evaluates numerical expressions on…
permissive · top 5,000 on PyPI
json-numpyProvides lossless JSON encoding and decoding…
permissive · top 15,000 on PyPI
nptypingProvides type hints and runtime type checking…
permissive · top 15,000 on PyPI
numpy-groupiesProvides optimized group-indexing operations on…
permissive · top 15,000 on PyPI
tag-expressionsParses and evaluates logical tag expressions…
copyleft · top 15,000 on PyPI
lovely-numpyProvides a human-readable summary of NumPy…
permissive · top 15,000 on PyPI