Metadata-Version: 2.4
Name: sympy-poly-rust
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Dist: sympy>=1.12
License-File: LICENSE
License-File: NOTICE
Summary: Rust port of the sympy/sympy polys-domain kernel (dense arithmetic over QQ)
Keywords: sympy,polynomial,rust
Author: sympy-rust contributors
Maintainer: sympy-rust publishers
License-Expression: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/John-Cusack/sympy-rust
Project-URL: Upstream, https://github.com/sympy/sympy

# sympy-rust

Rust port of the [`sympy/sympy`](https://github.com/sympy/sympy)
polys-domain kernel: dense polynomial arithmetic over `QQ` plus the `QQ`
domain operations. See `NOTICE` for upstream attribution.

## Scope

Kernel-scoped, not a mirror bid. SymPy is 497K LOC of pure Python; the
rustsmith headroom probe graded the two candidate kernels:

| kernel | score | verdict |
|---|---|---|
| polys-domains (`dup_mul` + `pythonmpq` QQ ops) | 0.85 | rewrite |
| simplify-core (9-module dispatch) | 0.49 | upstream_only — out of scope |

Port seam: `dup_mul`/`dup_add`/`dup_sub`/`dup_gcd` (univariate dense over
QQ) + recursive `dmp_mul` (multivariate) + `QQ` exact rationals. GCD
output is monic (unit-normalized, as upstream). Expand only with measured
wins.

## Layout

- `sympy-poly-core/` — reusable Rust core, no Python dependency.
- `src/lib.rs` — thin PyO3 binding (`sympy_poly._core`).
- `sympy_poly/` — Python converters (`Poly` ↔ dense lists).
- `tests/test_equivalence.py` — exact-equality corpus vs sympy.
- `bench/` — two-track wall + peak-RSS benches, measured-only.

## Install

Published as `sympy-poly-rust` (version 0.1.0). The 0.1.0 files land on
TestPyPI first (same wheel + sdist, same SHA-256) and are promoted to PyPI;
until the production landing completes, install from TestPyPI:

```sh
pip install --index-url https://test.pypi.org/simple/ sympy-poly-rust==0.1.0
pip install sympy-poly-rust==0.1.0   # PyPI, once promoted
```

The Rust core is on crates.io as `sympy-poly-core` 0.1.0
(`cargo add sympy-poly-core`).

The Python layer converts coefficients with `sympy.QQ`, so `sympy` is a
runtime dependency of the installed package.

### From source

```sh
pip install maturin
maturin develop   # inside a virtualenv
pytest tests/
python bench/bench_poly.py
```

## Status

Kernel slice v0.1.0, measured on x86_64 / python 3.12.3 / sympy 1.14.0
(`bench/results.json`; wall = best-of-3, maxrss = process peak):

| workload | sympy wall (s) | rust wall (s) | speedup | sympy RSS (MB) | rust RSS (MB) |
|---|---|---|---|---|---|
| dup_mul_800 (univariate deg-800 dense QQ) | 0.212 | 0.042 | 5.06x | 46.3 | 46.9 |
| dmp_mul_3var (`(x+y+z+1)^12` squared) | 0.112 | 0.013 | 8.75x | 48.6 | 48.9 |
| dup_gcd_70 (heuristic-friendly shape) | 0.001 | 0.008 | 0.17x, slower | 49.0 | 48.9 |

Accuracy: `tests/test_equivalence.py` 9/9 exact vs sympy; core unit
tests 14/14 (`cargo test -p sympy-poly-core`); upstream kernel subset
(`test_densearith` + `test_densetools` + `test_euclidtools`) 105 passed
on origin as baseline.

Ranked follow-ups: heuristic (evaluation/interpolation) GCD for
heuristic-friendly shapes — the PRS here is correct but ties-or-loses
where sympy's heuristic fires; multivariate GCD; `factor` stays upstream.

## Release

`0.1.0` ships the `sympy-poly-rust` Python distribution (wheel + sdist)
and the `sympy-poly-core` Rust crate. Release scope, artifacts, and the
verification battery are recorded in `specs/release.md`; the lane config is
`release.toml`; upstream attribution is `NOTICE`.

