PyEventEngine
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.
Metadata
Release files for PyEventEngine 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 40.3 MB
Release files / pyeventengine-1.0.2-cp315-cp315t-win_amd64.whl
| Download URL | pyeventengine-1.0.2-cp315-cp315t-win_amd64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2ae36e48457fbe78159c9f9d6bc8cb3c2b1699a77c195f6bc308ac00722af3cd
|
|
BLAKE2b-256 checksum How to use checksums |
b46f246c8907dd6353792c2b38aa7eae1a30638a4f0d1d2f2acae9214da904c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyeventengine-1.0.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyeventengine-1.0.2-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
35d6c8ce9cb54a4b3c51b2b8b076c7298e4462be0c871b6a72ba6c82d1938e87
|
|
BLAKE2b-256 checksum How to use checksums |
f0b41fa9bd144b997efb2f18f05e932067d5a300d6d6f1a27a797ccdbb9cbb30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyeventengine-1.0.2-cp315-cp315-win_amd64.whl
| Download URL | pyeventengine-1.0.2-cp315-cp315-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.15 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7f545b3806afa3a94e02150417f08e2db5108aff3cd146765e8e21e5d08d51d2
|
|
BLAKE2b-256 checksum How to use checksums |
0047637bce053dbff3f808f3aa1cccb59bed19827a1c9a8e4b9bdaeb518b38b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyeventengine-1.0.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyeventengine-1.0.2-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.15 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
8685b9d56d27e73fdfd888e40a15cee7d31e5002add9a5348ada025b867df969
|
|
BLAKE2b-256 checksum How to use checksums |
3372f99990abf20f843f54a6ff6726b4cb3ff68815aeffeb47f019b9dddfe3aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyeventengine-1.0.2-cp314-cp314t-win_amd64.whl
| Download URL | pyeventengine-1.0.2-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
147e1a7f7fe403a0444ce15b1387e2f760b4104b2556402648977de1142c2d93
|
|
BLAKE2b-256 checksum How to use checksums |
d3d43c62ae3835e733b40d1487a270be6e424cd8ce54ba979a112ddd8b4f7984
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyeventengine-1.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyeventengine-1.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6484dde3ed99a47991a0de631775c353cdf7aa03d3e9a4951dd738ca223d2ae3
|
|
BLAKE2b-256 checksum How to use checksums |
cb58b8eaa7034f77e018cf41e33a88fb1b3ce8c8a3debf53cbdab71fe2472b11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyeventengine-1.0.2-cp314-cp314-win_amd64.whl
| Download URL | pyeventengine-1.0.2-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7f3b6364364ec0246d0f27ae02dc72bbcc2a525426a7703bd0504bc09f11bc0e
|
|
BLAKE2b-256 checksum How to use checksums |
80a08a7197f4efd26cfd287b90a7d77d237b97d8977f967e6fba62490b6aef5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyeventengine-1.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyeventengine-1.0.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.4 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3b7546cdeb2bd49c587129cdb5a3fa68ad0381618fb68dd84f74f393e96aaebd
|
|
BLAKE2b-256 checksum How to use checksums |
5dcf28fbec88a46496379995b5026b7fafd1b20f4b33d7f3134f76067b8a8d1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyeventengine-1.0.2-cp313-cp313-win_amd64.whl
| Download URL | pyeventengine-1.0.2-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4483cce5817996f01ea147023ba13148c3337d0b53126dd067ca45e23e0bb188
|
|
BLAKE2b-256 checksum How to use checksums |
80254a72221e59910145ab99bc3ec89664aa1ffce317dfad38a6aeb41dd37455
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyeventengine-1.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyeventengine-1.0.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
82103ab3994f75c6f5a1f77faf41c5e0ddf6c9c3bc8e2c5996c21e44b0f83ebb
|
|
BLAKE2b-256 checksum How to use checksums |
50d6834d65e8724c332387c8807d37e699b5b147bbd26827c051e85d891a28bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pyeventengine-1.0.2-cp312-cp312-win_amd64.whl
| Download URL | pyeventengine-1.0.2-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
045898921397202fbb07f743ec6187a208614b73985311607ec93c305d5751b0
|
|
BLAKE2b-256 checksum How to use checksums |
1461556bee8477df69a9307ba2f73e101427eb159277e9a07da57a46fbadfb32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / pyeventengine-1.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyeventengine-1.0.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
91d3d4ed76f0aa58617943711659ee7c2732ef155fccbe7af5a32260b4bc1dc8
|
|
BLAKE2b-256 checksum How to use checksums |
2d58bcf02f73782cfe151a2b5b8dbdafd4cc980173db78ff898ea314af6772fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|