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 16x faster on average across complex real-world expressions, up to 25x on simple arithmetic:
| Case | simpleeval | gaia-simpleeval | Speedup |
|---|---|---|---|
| basic arithmetic | 7.09 us | 0.29 us | 25x |
| pythagorean distance | 11.34 us | 0.56 us | 20x |
| complex boolean | 16.76 us | 0.78 us | 22x |
| price calculation | 10.50 us | 0.61 us | 17x |
| grade evaluation | 17.04 us | 1.03 us | 17x |
| deep arithmetic | 17.63 us | 1.02 us | 17x |
| AVERAGE | 11.72 us | 0.72 us | 17x |
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
- 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.3.tar.gz.
File metadata
- Download URL: gaia_simpleeval-0.1.3.tar.gz
- Upload date:
- Size: 51.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fc9304042532acf4da5e26bcea298d721f93e012aa9e522e9a990e8952c5595
|
|
| MD5 |
ca655bc7619f73dc0c2e65c66d9a2d3f
|
|
| BLAKE2b-256 |
be519e69d87ff5d8ac6f85005923ac46c36e660a520bc7df8dd14d58c60aeec8
|
File details
Details for the file gaia_simpleeval-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: gaia_simpleeval-0.1.3-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 |
ab119a07c64c5cdab58554f3790b2af48d210e7fce61488bf3b48744a9a01fc8
|
|
| MD5 |
3dadaf74a1b5e274b3f58f0c22fa11cc
|
|
| BLAKE2b-256 |
94e45350a043de854abb44055831a12a7674b46f033b341a1ad99ad8b23d1a95
|