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.

Metadata

Release files for PyEventEngine 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for PyEventEngine 1.0.5
File Actions
pyeventengine-1.0.5-cp315-cp315t-win_amd64.whl CPython 3.15 CPython 3.15 free-threading Windows x86-64 Details for pyeventengine-1.0.5-cp315-cp315t-win_amd64.whl
pyeventengine-1.0.5-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details for pyeventengine-1.0.5-cp315-cp315-win_amd64.whl
pyeventengine-1.0.5-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for pyeventengine-1.0.5-cp314-cp314t-win_amd64.whl
pyeventengine-1.0.5-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for pyeventengine-1.0.5-cp314-cp314-win_amd64.whl
pyeventengine-1.0.5-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for pyeventengine-1.0.5-cp313-cp313-win_amd64.whl
pyeventengine-1.0.5-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for pyeventengine-1.0.5-cp312-cp312-win_amd64.whl

Total release size: 13.4 MB

Release files / pyeventengine-1.0.5-cp315-cp315t-win_amd64.whl

Download URL pyeventengine-1.0.5-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
f5a4e6d34da81709604922a0893a5b1181ea082c1d9a80e875e086ce386aadcd
BLAKE2b-256 checksum
How to use checksums
1ea1d0572cf7a0ad9deeff794d28e81c10110b935a89176f98ec39bb7d733569
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.5-cp315-cp315-win_amd64.whl

Download URL pyeventengine-1.0.5-cp315-cp315-win_amd64.whl
Size 2.2 MB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
120e4ea6410c6799ee95fe1fee180fbcffafbb7217b2bd203b6ee5e58ee5850a
BLAKE2b-256 checksum
How to use checksums
dfdf2a6fe7f34ffbdcf57da54d01a2506556078d3e065048d4a87a177984df6a
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.5-cp314-cp314t-win_amd64.whl

Download URL pyeventengine-1.0.5-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
6795a707d659ea09345cd865e7a55e9808b1007c391106abd0d3a8e465738d41
BLAKE2b-256 checksum
How to use checksums
75e50a22ff26f73e99285393ab121f0aa18eea50d1251031dc566e00d257a9be
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.5-cp314-cp314-win_amd64.whl

Download URL pyeventengine-1.0.5-cp314-cp314-win_amd64.whl
Size 2.2 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
682e2246564c17c7038c2ff7c0b9958383b33dbfe4c736e6f2e328b296acb9ce
BLAKE2b-256 checksum
How to use checksums
e431cb3969c2c4e737c75cb644915cfb3c0a0bafa923920b24a57bffe7b9e8e8
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.5-cp313-cp313-win_amd64.whl

Download URL pyeventengine-1.0.5-cp313-cp313-win_amd64.whl
Size 2.2 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
02cd094b4bcba022b67a3db34aadb5aee2bea8037edd41a6c00a5feaceb78c5e
BLAKE2b-256 checksum
How to use checksums
b971efc805755224552360a1044061821a78b8ece10edc442f39f869c81fc7e0
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.5-cp312-cp312-win_amd64.whl

Download URL pyeventengine-1.0.5-cp312-cp312-win_amd64.whl
Size 2.2 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
93717e753726e71f079b52d3a4320bd38dd2aaf9c385ca8bb8bc3381a65de2fe
BLAKE2b-256 checksum
How to use checksums
f25040ea88645a8ad9101c9a2df7a59459cfed4004da25d391bd7f0f48845521
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for PyEventEngine 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.5 This release

6 release files No provenance

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