Skip to main content

PyEventEngine

gitlab

GitHub Actions: ⛔ temporarily disabled — kept disabled until the GitHub Actions issue is resolved. See .github/workflows/README.md. CI runs on the GitLab mirror pipeline while disabled.

High-performance, topic-driven event engine for Python with a Cython-accelerated core and a native Python fallback.

  • Fast publish/subscribe event routing by topic (exact + generic wildcard/pattern matching)
  • Clean, typed API with drop-in fallback when C extensions are unavailable
  • Built-in timers, handler stats (EventHookEx), and convenient formatting helpers

Installation

# From PyPI (pre-compiled wheels available)
pip install PyEventEngine

# From source (requires C compiler + Cython ≥ 3.0)
git clone https://github.com/BolunHan/PyEventEngine.git
cd PyEventEngine

# Build + install
./build.sh -i

# Or via Makefile:
make build && pip install -U . --no-build-isolation

# Or step by step:
python setup.py build_ext --inplace --verbose --force
pip install -U . --no-build-isolation

See the Installation Guide for platform-specific prerequisites, compile-time macros, and troubleshooting.

Quick Start

import time
from event_engine import EventEngine, Topic

# Create and start the engine
engine = EventEngine(capacity=8192)
engine.start()

# Register a handler for an exact topic
exact = Topic('Demo.Hello')

def hello_handler(name: str, topic=None):
    print(f"Hello {name} from {topic.value if topic else 'N/A'}")

engine.register_handler(exact, hello_handler)

# Publish a message
engine.put(exact, 'World')

# Clean up
time.sleep(0.1)
engine.stop()
engine.clear()

Generic topics (wildcards/patterns)

import time
from event_engine import Topic, EventEngine

engine = EventEngine()
pattern = Topic('Demo.{what}')

calls = []

def f(what: str, topic=None):
    calls.append((what, topic.value))

engine.register_handler(pattern, f)

engine.start()
engine.put(Topic('Demo.Test'), 'a test sub-topic')
engine.put(Topic('Demo.Live'), 'a live sub-topic')
time.sleep(0.1)  # allow time for processing
engine.stop()

print(calls)  # [('a test sub-topic', 'Demo.Test'), ('a live sub-topic', 'Demo.Live')]

Timers (EventEngineEx)

import time
from event_engine import EventEngineEx, Topic

engine = EventEngineEx(capacity=4096)
engine.start()

# Create a 1-second timer topic and subscribe
timer_topic = engine.get_timer(1.0)
engine.register_handler(timer_topic, lambda **kw: print('tick', kw))

time.sleep(3)
engine.stop()
engine.clear()

Logging

By default, the package uses a colored logger under event_engine.base. To integrate with your application's logging, call set_logger once after import — it propagates to submodules.

import logging
from event_engine import set_logger

logger = logging.getLogger('MyApp')
logger.setLevel(logging.INFO)
set_logger(logger)

Fallback behavior

On import, the package tries to use the Cython implementation (event_engine.capi). If that fails (e.g., no compiler available), it automatically falls back to the native Python implementation (event_engine.native). Check the active backend:

from event_engine import USING_FALLBACK
print('Using native fallback?', USING_FALLBACK)

Development

# Clone and build in-place
git clone https://github.com/BolunHan/PyEventEngine.git
cd PyEventEngine
./build.sh -i

# Run tests
python -m pytest demo/

# Performance benchmarks
python demo/native_performance_test.py
python demo/capi_performance_test.py       # requires compiled extensions

Build scripts

Command Effect
./build.sh -i Clean + build + install
./build.sh -l List compile-time macros
make build Clean + build in-place
make clean-all Deep clean (removes .c/.so)

Documentation

Full documentation: https://bolunhan.github.io/PyEventEngine/

Build locally:

pip install sphinx furo sphinx-autodoc-typehints
cd docs
sphinx-build -M html . _build
# Open _build/html/index.html

License

MIT — see LICENSE.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pyeventengine-1.0.2-cp315-cp315t-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.15tWindows x86-64

pyeventengine-1.0.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.15tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pyeventengine-1.0.2-cp315-cp315-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.15Windows x86-64

pyeventengine-1.0.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

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

pyeventengine-1.0.2-cp314-cp314t-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.14tWindows x86-64

pyeventengine-1.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.6 MB view details)

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

pyeventengine-1.0.2-cp314-cp314-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.14Windows x86-64

pyeventengine-1.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.4 MB view details)

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

pyeventengine-1.0.2-cp313-cp313-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.13Windows x86-64

pyeventengine-1.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

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

pyeventengine-1.0.2-cp312-cp312-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.12Windows x86-64

pyeventengine-1.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

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

File details

Details for the file pyeventengine-1.0.2-cp315-cp315t-win_amd64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp315-cp315t-win_amd64.whl
Algorithm Hash digest
SHA256 2ae36e48457fbe78159c9f9d6bc8cb3c2b1699a77c195f6bc308ac00722af3cd
MD5 70fa0966a86c354a479fe567c256e0e2
BLAKE2b-256 b46f246c8907dd6353792c2b38aa7eae1a30638a4f0d1d2f2acae9214da904c7

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 35d6c8ce9cb54a4b3c51b2b8b076c7298e4462be0c871b6a72ba6c82d1938e87
MD5 71fc3f0caa898f75fa46924b3da58f03
BLAKE2b-256 f0b41fa9bd144b997efb2f18f05e932067d5a300d6d6f1a27a797ccdbb9cbb30

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp315-cp315-win_amd64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp315-cp315-win_amd64.whl
Algorithm Hash digest
SHA256 7f545b3806afa3a94e02150417f08e2db5108aff3cd146765e8e21e5d08d51d2
MD5 a015f36993e71142efc4c989b859d118
BLAKE2b-256 0047637bce053dbff3f808f3aa1cccb59bed19827a1c9a8e4b9bdaeb518b38b1

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8685b9d56d27e73fdfd888e40a15cee7d31e5002add9a5348ada025b867df969
MD5 544f992a7b14c1e2bc168333bcd9acee
BLAKE2b-256 3372f99990abf20f843f54a6ff6726b4cb3ff68815aeffeb47f019b9dddfe3aa

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 147e1a7f7fe403a0444ce15b1387e2f760b4104b2556402648977de1142c2d93
MD5 f5180ae5ddbf2dafec6f3f5c6d2164dc
BLAKE2b-256 d3d43c62ae3835e733b40d1487a270be6e424cd8ce54ba979a112ddd8b4f7984

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6484dde3ed99a47991a0de631775c353cdf7aa03d3e9a4951dd738ca223d2ae3
MD5 6a9b68dcf081f6d8895e8e2a1383cd76
BLAKE2b-256 cb58b8eaa7034f77e018cf41e33a88fb1b3ce8c8a3debf53cbdab71fe2472b11

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 7f3b6364364ec0246d0f27ae02dc72bbcc2a525426a7703bd0504bc09f11bc0e
MD5 d185cc8cfc10b6aab635aa71479a8e2b
BLAKE2b-256 80a08a7197f4efd26cfd287b90a7d77d237b97d8977f967e6fba62490b6aef5d

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b7546cdeb2bd49c587129cdb5a3fa68ad0381618fb68dd84f74f393e96aaebd
MD5 4bfe2029765370e0977843a213835bd9
BLAKE2b-256 5dcf28fbec88a46496379995b5026b7fafd1b20f4b33d7f3134f76067b8a8d1a

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4483cce5817996f01ea147023ba13148c3337d0b53126dd067ca45e23e0bb188
MD5 0b944a44a89050e429a53db648e03b28
BLAKE2b-256 80254a72221e59910145ab99bc3ec89664aa1ffce317dfad38a6aeb41dd37455

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 82103ab3994f75c6f5a1f77faf41c5e0ddf6c9c3bc8e2c5996c21e44b0f83ebb
MD5 a8adc1929b057a30c5513aa4209222d0
BLAKE2b-256 50d6834d65e8724c332387c8807d37e699b5b147bbd26827c051e85d891a28bf

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 045898921397202fbb07f743ec6187a208614b73985311607ec93c305d5751b0
MD5 8baaf7304b389404b63ff5d6f0acec45
BLAKE2b-256 1461556bee8477df69a9307ba2f73e101427eb159277e9a07da57a46fbadfb32

See more details on using hashes here.

File details

Details for the file pyeventengine-1.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyeventengine-1.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 91d3d4ed76f0aa58617943711659ee7c2732ef155fccbe7af5a32260b4bc1dc8
MD5 2e4ef57fc48fd8afbf4260c4874f1a70
BLAKE2b-256 2d58bcf02f73782cfe151a2b5b8dbdafd4cc980173db78ff898ea314af6772fa

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.2 This release

12 files

1.0.1

6 files

1.0.0

6 files

0.6.2.post1

12 files

0.6.2

12 files

0.6.0.post3

8 files

0.6.0.post2

4 files

0.6.0.post1

4 files

0.6.0

4 files

0.5.2.post3

4 files

0.5.2.post1

4 files

0.5.2

4 files

0.5.1.post1

4 files

0.5.1

4 files

0.5.0.post2

4 files

0.5.0.post1

4 files

0.4.6.post1

4 files

0.4.6

4 files

0.4.5

4 files

0.4.4.post1

4 files

0.4.4

4 files

0.3.2

2 files

0.3.0.post5

1 file

0.3.0.post4

1 file

0.3.0.post3

1 file

0.3.0.post2

1 file

0.3.0.post1

1 file

0.3.0

1 file

0.2.1

1 file

0.1.4

1 file

0.1.2

1 file

0.1.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page