Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _This project uses semantic versioning_

## UNRELEASED

- Allow changing number of threads with env variable [#330](https://github.com/egraphs-good/egglog-python/pull/330)
## 11.0.0 (2025-08-08)
- Change conversion between binary operators to consider converting both types [#320](https://github.com/egraphs-good/egglog-python/pull/320)
- Add ability to parse egglog expressions into Python values [#319](https://github.com/egraphs-good/egglog-python/pull/319)
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ pip install anywidget

It follows [SPEC 0](https://scientific-python.org/specs/spec-0000/) in terms of what Python versions are supported.

## Parallelism and threads

The underlying Rust library uses Rayon for parallelism. You can control the worker thread count via the environment variable `RAYON_NUM_THREADS`. If this variable is not set or is invalid, the Python bindings default to using a single thread (`1`).

```shell
export RAYON_NUM_THREADS=4 # use 4 threads
```

(community)=

## Community
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ use pyo3::prelude::*;
/// Bindings for egglog rust library
#[pymodule]
fn bindings(m: &Bound<'_, PyModule>) -> PyResult<()> {
// Configure Rayon thread pool from env var, defaulting to 1 if unset/invalid.
let num_threads = std::env::var("RAYON_NUM_THREADS")
.ok()
.and_then(|s| s.parse::<usize>().ok())
.unwrap_or(1);
rayon::ThreadPoolBuilder::new()
.num_threads(1)
.num_threads(num_threads)
.build_global()
.unwrap();

Expand Down