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.2.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.2-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.2.tar.gz.

File metadata

  • Download URL: gaia_simpleeval-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7f48d4060810da195ae06425477a881a38cb534a61e2ef958649a0eb86947f51
MD5 5ca9d7c1ba76b47d67b580e64bff860b
BLAKE2b-256 81147992c2f90b613397d523ec43462969dc59f258bdddd08f13b30df91da1ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gaia_simpleeval-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f59a7322701d00a5fc5d68fa971869ab17bc0379bdfad4a4ba8144aa791a414
MD5 7ffe4249d8c22b7682f03ef2edd20f58
BLAKE2b-256 3b49059e3f009110b6556c27a537fff53f0dce805f5e6aa84209b3d198be8423

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