Skip to main content

A transparent turbocharger for wolframclient.

Project description

wolfram-boost

A transparent turbocharger for wolframclient. One import, zero API changes.

PyPI version Python 3.8+ License: MIT

The official wolframclient gets sluggish with anything beyond tiny data—an 8 MB image takes 1.5 seconds, a short audio clip takes seconds. wolfram-boost swaps out the transport layer so the same data arrives in tens of milliseconds.

No API changes. No new concepts. Just a smoother experience.


The difference

Data size Official wolfram-boost Feels like
Tiny 7 ms 14 ms Same
Small 37 ms 9 ms Snappier
Medium 161 ms 17 ms Smooth
Image (8 MB) 1.5 s 50 ms Lag is gone
Large image (32 MB) 5.8 s 246 ms Actually usable
Heavy (80 MB+) Unusable Under 0.5 s Feels local

Benchmarks: ARM64 Linux, Wolfram Engine 14.3, 20-round median.


Installation

pip install wolfram-boost

Requirements:

· Python ≥ 3.8 · NumPy ≥ 1.20 · wolframclient · Wolfram Engine or Mathematica installed and configured · Linux only (relies on /dev/shm)


Quick start

# Before
from wolframclient.evaluation import WolframLanguageSession

# After
from wolfram_boost import SHMWolframSession

session = SHMWolframSession(
    kernel="/opt/Wolfram/WolframEngine/14.3/Executables/WolframKernel"
)

# Everything else is the same
from wolframclient.language import wl
import numpy as np

img = np.random.rand(4096, 4096, 3).astype(np.float32)
result = session.evaluate(wl.ImageMeasurements(img, "MeanIntensity"))

audio = np.random.randint(-32768, 32767, size=(2, 44100), dtype=np.int16)
result = session.evaluate(wl.Mean(wl.Flatten(audio)))

small = np.random.rand(100, 2)
result = session.evaluate(wl.Mean(wl.Flatten(small)))

session.terminate()

How it works

You don't need to know. But if you're curious:

Your data
    │
    ├── small → normal ZMQ path (no overhead)
    │
    └── large → high-speed bypass → Wolfram Engine
                    │
              files cleaned up automatically

The decision is automatic. You can tweak the threshold if you want:

session = SHMWolframSession(kernel="...", threshold=10*1024)  # 10 KB

Supported data types

Everything you're likely to throw at Wolfram Engine:

float32 · float64 · float16 · int8 · int16 · int32 · int64 · uint8 · uint16 · uint32 · uint64 · complex64 · complex128 · bool


API

SHMWolframSession is a drop-in replacement for WolframLanguageSession. Same methods, same signatures. You can also use the alias BoostSession if you prefer:

from wolfram_boost import BoostSession

Limitations

· Linux only (uses /dev/shm) · Python and Wolfram Engine must run on the same machine · For multi-GB arrays, call np.ascontiguousarray() first


Tests

# Functional smoke test (all data types, cleanup verification)
python3 tests/smoke_test.py

# Benchmark (SHM vs ZMQ)
python3 tests/benchmark_shm_vs_zmq.py

# Extreme stress test (up to 512 MB+)
python3 tests/benchmark_hell.py

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

wolfram_boost-0.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

wolfram_boost-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file wolfram_boost-0.1.0.tar.gz.

File metadata

  • Download URL: wolfram_boost-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for wolfram_boost-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef0b3f371fedb994008498f26ddd6fc6bb88e9b3c0d708c9c7ee293fc102186f
MD5 bc02e38209694a5507db8cddcafd9a3a
BLAKE2b-256 70d094c0f55726d2d43418c755255f7bd2f69718441547216651ac2b1b13b3a9

See more details on using hashes here.

File details

Details for the file wolfram_boost-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wolfram_boost-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for wolfram_boost-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8bcf1bd6c4913311c43d749370efe6c098dee52e647eff634cc3a281aef8372
MD5 cdd6fec60097e5e9011c09c40b42e542
BLAKE2b-256 4ba3ec6d09e43c721f084059f948f90e0a8333a39ed443e5867e8073d6b4455a

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