Python bindings for Cimba, a multithreaded discrete-event-simulation C library
Project description
Cimba Python
Fast discrete event simulation for Python
Cimba Python is a Python interface to Cimba, a multithreaded discrete event simulation engine written in C and assembly.
It is designed for Python simulation models that need more speed than pure Python event scheduling can usually provide. In the included M/M/1 benchmark, Cimba Python runs about 27-33x faster than SimPy after its one-time Numba compile, while keeping model code in Python.
On an AMD Ryzen 7 9700X under WSL Ubuntu 24.04, averaged over 10 runs:
| Benchmark | SimPy | Cimba Python | Cimba C |
|---|---|---|---|
| Single core, single trial | 2.612 s | 0.096 s | 0.083 s |
| Multicore, 100 trials | 36.807 s | 1.131 s | 0.970 s |
The benchmark data and charts are in
benchmark/AMD_Ryzen_7_9700X_WSL.ods.
Install
pip install cimba
or with uv:
uv add cimba
Python 3.13 or newer is required. The wheel embeds the Cimba C library, so you do not need to install Cimba separately.
What is it?
Cimba Python gives Python models access to Cimba's native simulation engine
through the cimba.sim API: processes, event queues, buffers, queues, stores,
priority queues, resources, resource pools, conditions, timers, events, random
distributions, logging helpers, and experiment tables.
What does the code look like?
import cimba.sim as sim
class MM1(sim.Model):
utilization: sim.Param
avg_queue_length: sim.Output
queue: sim.Queue
model = MM1("MM1")
@model.process
def arrival(env: MM1):
while True:
sim.hold(sim.exponential(1.0 / env.utilization))
sim.put(env.queue, 1)
@model.process
def service(env: MM1):
while True:
sim.get(env.queue, 1)
sim.hold(sim.exponential(1.0))
@model.collect
def collect_stats(env: MM1):
env.avg_queue_length = sim.mean_level(env.queue)
exp = model.experiment(
utilization=0.75,
replications=100,
duration=1000.0,
warmup=100.0,
seed=123,
)
exp.run()
print(exp["avg_queue_length"].mean())
More examples, tutorials, background notes, and the API reference are in the documentation.
Development
From a fresh clone:
git submodule update --init --recursive
uv sync
uv run pytest
License
Cimba Python is licensed under Apache-2.0. See LICENSE and
NOTICE.
The bundled Cimba C library is also Apache-2.0 licensed. See
subprojects/cimba/NOTICE for attribution.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cimba-0.3.0.tar.gz.
File metadata
- Download URL: cimba-0.3.0.tar.gz
- Upload date:
- Size: 7.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9700c290ca97b6c8363c9af356e7943ac93e02e54e2eb78976133910933bc23
|
|
| MD5 |
f882745eeceec2b3d10bcd2f9bfe497c
|
|
| BLAKE2b-256 |
cdbd5306c398faa996a4acf37a278501ee3023278c5cefa82c37aa3b30e3ca8c
|
Provenance
The following attestation bundles were made for cimba-0.3.0.tar.gz:
Publisher:
release.yml on FBarrca/cimba_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cimba-0.3.0.tar.gz -
Subject digest:
b9700c290ca97b6c8363c9af356e7943ac93e02e54e2eb78976133910933bc23 - Sigstore transparency entry: 2048788883
- Sigstore integration time:
-
Permalink:
FBarrca/cimba_python@3314720eec33d15c0146b0acdd7416063598e079 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/FBarrca
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3314720eec33d15c0146b0acdd7416063598e079 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cimba-0.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cimba-0.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 479.6 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caf712d48fe5dc51489c8053b960b6468c34f7e5e0889695d37588364847fec4
|
|
| MD5 |
59f4cf4a87f1b27dcf5731258539fec3
|
|
| BLAKE2b-256 |
8d6faa65283d544eeb1ec07679f3d159dd11f1aea5949c584fc7de41f84d4536
|
Provenance
The following attestation bundles were made for cimba-0.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on FBarrca/cimba_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cimba-0.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
caf712d48fe5dc51489c8053b960b6468c34f7e5e0889695d37588364847fec4 - Sigstore transparency entry: 2048789074
- Sigstore integration time:
-
Permalink:
FBarrca/cimba_python@3314720eec33d15c0146b0acdd7416063598e079 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/FBarrca
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3314720eec33d15c0146b0acdd7416063598e079 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cimba-0.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: cimba-0.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 475.0 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34b5c5d608bc4231f65bae7ea3a56a016b0bea3fe9181c12660eadf95567eb99
|
|
| MD5 |
5aef89f36a0d2161b1ae1ce15d3ae967
|
|
| BLAKE2b-256 |
6513db406506a80a1dd2edb19a2f73d83f897e63f0e1365f0f568060c5df5dd9
|
Provenance
The following attestation bundles were made for cimba-0.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on FBarrca/cimba_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cimba-0.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
34b5c5d608bc4231f65bae7ea3a56a016b0bea3fe9181c12660eadf95567eb99 - Sigstore transparency entry: 2048788979
- Sigstore integration time:
-
Permalink:
FBarrca/cimba_python@3314720eec33d15c0146b0acdd7416063598e079 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/FBarrca
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3314720eec33d15c0146b0acdd7416063598e079 -
Trigger Event:
push
-
Statement type: