Skip to main content

Delta Cycle

Project description

Delta Cycle

DeltaCycle is a Python library for discrete event simulation (DES).

A simulation has two components: a collection of variables, and a collection of tasks. Variables represent the instantaneous state of the simulation. They may be organized into arbitrary data structures. Tasks define how that state evolves. They may appear concurrent, but are scheduled sequentially.

Task execution is subdivided into a sequence of slots. Slots are assigned a monotonically increasing integer value, called time. Multiple tasks may execute in the same slot, and therefore at the same time. The term "delta cycle" refers to a zero-delay subdivision of a time slot. It is the clockwork mechanism behind the illusion of concurrency.

Read the docs! (WIP)

Documentation Status

Features

  • Kernel: task scheduler
  • Task: coroutine wrapper
  • Synchronization Primitives:
    • Events
    • Semaphores
    • Credit Pools
    • Queues
    • Containers
  • Structured Concurrency:
    • Task Groups (parent/child hierarchy)
    • Interrupts
    • Exceptions
  • Model Variables:
    • Singular
    • Aggregate

Example

The following code simulates two clocks running concurrently. The fast clock prints the current time every time step. The slow clock prints the current time every two time steps.

>>> from deltacycle import now, run, sleep

>>> async def clock(name: str, period: int):
...     while True:
...         print(now(), name)
...         await sleep(period)

>>> async def main():
...     create_task(clock("fast", 1))
...     create_task(clock("slow", 2))

>>> run(main(), until=6)
0 fast
0 slow
1 fast
2 slow
2 fast
3 fast
4 slow
4 fast
5 fast

Installing

DeltaCycle is available on PyPI:

$ pip install deltacycle

It requires Python 3.12+

Developing

DeltaCycle's repository is on GitHub:

$ git clone https://github.com/cjdrake/deltacycle.git

It is 100% Python, and has no runtime dependencies. Development dependencies are listed in requirements-dev.txt.

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

deltacycle-0.29.1.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

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

deltacycle-0.29.1-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file deltacycle-0.29.1.tar.gz.

File metadata

  • Download URL: deltacycle-0.29.1.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for deltacycle-0.29.1.tar.gz
Algorithm Hash digest
SHA256 adcfa4b208c2f33faa7e0dfca2b6e8fcf1a820b8049dc0d2f68723b56a6c507f
MD5 fb71e2c68ac2f3f1897e4ecd782004e2
BLAKE2b-256 048867f25a0e9d49afec2dda01d4e00a58c3fd964fbc2aa76744213d086254bd

See more details on using hashes here.

File details

Details for the file deltacycle-0.29.1-py3-none-any.whl.

File metadata

  • Download URL: deltacycle-0.29.1-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for deltacycle-0.29.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f3f42123c7fec23c9ddd3555609c1d50cd522eb038d7c8c54a3952b71dff9b9
MD5 f4b5a5c7fed3fddca0b1a90cac9292b6
BLAKE2b-256 64f7d3637ca46efa35c520dab547ebcf7c6174d5b6a0bc44eb69382c75991b00

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