Skip to main content

Python bindings for Cimba, a multithreaded discrete-event-simulation C library

Project description

Cimba logo

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cimba-0.3.0.tar.gz (7.1 MB view details)

Uploaded Source

Built Distributions

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

cimba-0.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (479.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

cimba-0.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (475.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

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

Hashes for cimba-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b9700c290ca97b6c8363c9af356e7943ac93e02e54e2eb78976133910933bc23
MD5 f882745eeceec2b3d10bcd2f9bfe497c
BLAKE2b-256 cdbd5306c398faa996a4acf37a278501ee3023278c5cefa82c37aa3b30e3ca8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimba-0.3.0.tar.gz:

Publisher: release.yml on FBarrca/cimba_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

File hashes

Hashes for cimba-0.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 caf712d48fe5dc51489c8053b960b6468c34f7e5e0889695d37588364847fec4
MD5 59f4cf4a87f1b27dcf5731258539fec3
BLAKE2b-256 8d6faa65283d544eeb1ec07679f3d159dd11f1aea5949c584fc7de41f84d4536

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

File hashes

Hashes for cimba-0.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 34b5c5d608bc4231f65bae7ea3a56a016b0bea3fe9181c12660eadf95567eb99
MD5 5aef89f36a0d2161b1ae1ce15d3ae967
BLAKE2b-256 6513db406506a80a1dd2edb19a2f73d83f897e63f0e1365f0f568060c5df5dd9

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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