High-performance drop-in replacement for simpleeval using Rust
Project description
gaia-simpleeval
A high-performance drop-in replacement for simpleeval, implemented in Rust via PyO3.
Installation
pip install gaia-simpleeval
Usage
No code changes required. gaia-simpleeval automatically patches simpleeval at import time:
import gaia_simpleeval import simpleeval
result = simpleeval.simple_eval("2 + 2 * 3")
Or use the gaia API directly:
import gaia_simpleeval as gse result = gse.simple_eval("x + y", names={"x": 1, "y": 2})
Performance
More than 20x faster than the original simpleeval on typical expressions:
| Expression | simpleeval | gaia-simpleeval | Speedup |
|---|---|---|---|
| 2+2 | 8.1 us | 0.36 us | 22x |
| 2+2*3 | 9.6 us | 0.37 us | 26x |
| x+y (names) | 8.2 us | 0.58 us | 14x |
| 1<2 | 8.6 us | 0.40 us | 21x |
| 3.14*2.0 | 8.2 us | 0.36 us | 23x |
Compatibility
- Drop-in replacement — all simpleeval APIs work unchanged
- Supports Python 3.9 through 3.13
- Falls back to original simpleeval for advanced usage (custom operators, allowed_attrs)
- All 205 simpleeval compatibility tests pass
Security
gaia-simpleeval preserves all simpleeval security constraints:
- No access to builtins, imports, or file system
- Module objects in names raise FeatureNotAvailable
- Dunder functions raise FunctionNotDefined
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gaia_simpleeval-0.1.0.tar.gz.
File metadata
- Download URL: gaia_simpleeval-0.1.0.tar.gz
- Upload date:
- Size: 51.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492795eca161a1e030aa9e7e62077cd998fe22b224893654e27b05c27c1c7ba6
|
|
| MD5 |
d41a1a10c6a46a43c4a3ff99307ae804
|
|
| BLAKE2b-256 |
43dfb4042c17a9734bdafdfe36a25d7da8312ee31e06833ef2b0d679017d48e9
|
File details
Details for the file gaia_simpleeval-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: gaia_simpleeval-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 313.4 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a334b30acd34b1de6a6b190fcb6d3db298d54eae1ed5fb8e024c65e46e6e1e4c
|
|
| MD5 |
100083cfe78aaacff9d666bc2b8bf08b
|
|
| BLAKE2b-256 |
c3abc78222e921cf8b98dbeb093a542e98a7ff979e8d34944f55cced08a31c1e
|