Skip to main content

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:

Expression 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

gaia_simpleeval-0.1.1.tar.gz (51.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gaia_simpleeval-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (313.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file gaia_simpleeval-0.1.1.tar.gz.

File metadata

  • Download URL: gaia_simpleeval-0.1.1.tar.gz
  • Upload date:
  • Size: 51.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for gaia_simpleeval-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b0a8b059463c76870210525d2bd08e80cdb7bc3288f64821b3faa7fac37e6de1
MD5 a1bf5b5ce9bc3250a1aa4d25bdcabd36
BLAKE2b-256 ca0573a0ede6adbe516ffc2dba3c295f4f74f45905235382dcf64b47ead18152

See more details on using hashes here.

File details

Details for the file gaia_simpleeval-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gaia_simpleeval-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b4b4ac9c98d1d8e8a97427fbe0564017d99728dbfafef51dffb8dd7e37182120
MD5 a378ccb645c719f5799516d4e7f0976a
BLAKE2b-256 98b8ef04d6d47cd006122147e8e538eadfe06f078256a6d01486fd4767934ba8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page