symbolite: a minimal symbolic Python package
Symbolite lets you build mathematical expressions with ordinary Python operators. Keep expressions symbolic, substitute values, and translate them into numerical results, SymPy expressions, or code using a selected backend.
Installation
Requires Python 3.12 or later.
pip install -U symbolite
Quick start
Use Symbol for generic symbolic values, Real for real scalars, and Vector
for vectors.
from symbolite import Real, substitute, translate
from symbolite.impl import libstd
from symbolite.ops import as_code
x, y = Real("x"), Real("y")
expr = x + 3 * y
print(as_code(expr)) # x + 3 * y
filled = substitute(expr, {x: 5, y: 2})
print(as_code(filled)) # 5 + 3 * 2
print(translate(filled, libstd)) # 11
Substitution builds another symbolic expression. Translation uses the backend
passed as libsl to evaluate or represent it. Numerical backends require values
for named inputs; SymPy can keep them symbolic. Use as_code to display an
expression as Python code.
Mathematical functions are available in real and vector:
from symbolite import Vector, real, vector
print(translate(real.cos(0), libstd)) # 1.0
v = Vector("v")
total = vector.sum(v)
print(translate(substitute(total, {v: (1, 2, 3)}), libstd)) # 6.0
Backends
Implementations live in symbolite.impl. Install optional libraries separately
when using their backends.
| Backend | Purpose |
|---|---|
libstd |
Numerical evaluation with the Python standard library |
libnumpy |
NumPy array operations |
libjax |
JAX array operations |
libsympy |
SymPy symbolic expressions |
libpythoncode |
Python source generation |
liblatex |
LaTeX expression formatting |
from symbolite.impl import libsympy
print(translate(expr, libsympy)) # x + 3*y
Supported operations and numerical behavior depend on the backend. For example, standard-library lists and tuples support vector indexing and reductions; NumPy and JAX arrays also support vector arithmetic and elementwise comparisons.
Packing scalar inputs into a vector
vector.vectorize replaces selected scalar symbols with vector elements and
returns (vector, rewritten_expression):
state, rewritten = vector.vectorize(expr, order=(x, y))
print(translate(substitute(rewritten, {state: (5, 2)}), libstd)) # 11
Use into=Vector("state") to supply a named vector, or indices={x: 3, y: 5}
instead of order to choose explicit positions. vector.auto_vectorize(expr)
selects free scalar inputs automatically; vector.vector_inputs(expr) gives
their order.
User functions
Wrap a Python callable to use it in symbolic expressions:
from symbolite import UserFunction
def abs_times_two(value):
return 2 * abs(value)
uf = UserFunction.from_function(abs_times_two)
print(translate(uf(-1), libstd)) # 2
Register a backend-specific implementation with
uf.register_impl(function, libsl=backend).
Symbolic conditions
Use & and | to combine symbolic conditions, such as (0 < x) & (x < 10).
Evaluate conditions explicitly with translate before using them in Python
control flow. Symbolic expressions cannot be used directly with bool(), not,
and, or, or chained comparisons.
Python == and != compare symbolic objects structurally. Use .eq() and
.ne() to build mathematical equality and inequality expressions.
Building larger workflows
AssignandBlockinsymbolite.abstractdescribe computations with inputs and outputs. Numerical backends translate blocks into callable functions;libpythoncodegenerates their source.symbolite.ops.traversalprovides walking, rewriting, transformation, and structural adapters for custom types.symbolite.ops.tree_viewdisplays the structure of an expression.
Metadata
Release files for symbolite 1.3.0
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 |
|---|---|---|---|---|
| symbolite-1.3.0.tar.gz | 71.1 kB | Without provenance | Details for symbolite-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| symbolite-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for symbolite-1.3.0-py3-none-any.whl |
Total release size: 185.0 kB
Release files / symbolite-1.3.0.tar.gz
| Download URL | symbolite-1.3.0.tar.gz |
|---|---|
| Size | 71.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23300cecaf7372c01106bb7ef60d40c4d985ca10232a52b3ed7447ef9eac760d
|
|
BLAKE2b-256 checksum How to use checksums |
b5735287347830d07b65a67b6bac0c57e1082034818ec5e6eef1863609a57cd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / symbolite-1.3.0-py3-none-any.whl
| Download URL | symbolite-1.3.0-py3-none-any.whl |
|---|---|
| Size | 113.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
031b803cc625377479187f4a37e7df133d8ad57cb805fb57e5917de67beba756
|
|
BLAKE2b-256 checksum How to use checksums |
f480dd83e4f49974ca547fa30072f298b1a8c984c6b2b054276c877529b77fbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for symbolite 1.3.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.