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:

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

gaia_simpleeval-0.1.3.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.3-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.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

Hashes for gaia_simpleeval-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5fc9304042532acf4da5e26bcea298d721f93e012aa9e522e9a990e8952c5595
MD5 ca655bc7619f73dc0c2e65c66d9a2d3f
BLAKE2b-256 be519e69d87ff5d8ac6f85005923ac46c36e660a520bc7df8dd14d58c60aeec8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gaia_simpleeval-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab119a07c64c5cdab58554f3790b2af48d210e7fce61488bf3b48744a9a01fc8
MD5 3dadaf74a1b5e274b3f58f0c22fa11cc
BLAKE2b-256 94e45350a043de854abb44055831a12a7674b46f033b341a1ad99ad8b23d1a95

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