A high-performance domain events library for Python applications.
Project description
Domain Events ⚡
Ultra-fast events system for Python, optimized for high performance and production-ready.
Features
- 🚀 7-8x faster than Django Signals
- 💾 Memory-efficient 60% less usage compared to Django Signals
- 🔧 Type-safe with DTOs
- 🎯 Simple and robust
- 🔌 Celery integration
Installation
Core dependencies
pip install -r requirements/requirements.txt
Cython acceleration (recommended for production)
Build and install the Cython module in editable mode so it's available throughout your environment:
pip install cython
pip install -e ./cython_core
This will compile and link the accelerated module automatically. No need to modify PYTHONPATH.
Development dependencies
Includes everything needed for testing, benchmarks and development:
pip install -r requirements/requirements-dev.txt
Quick Start
from domain_events import DomainEventSystem, DomainEvent
from dataclasses import dataclass
@dataclass(frozen=True)
class UserRegisteredEvent(DomainEvent):
event_type = "user.registered"
user_id: int
email: str
system = DomainEventSystem()
def send_welcome_email(event: UserRegisteredEvent):
print(f"Welcome {event.email}!")
system.register_event(
"user.registered",
UserRegisteredEvent,
[(send_welcome_email, {"async": True})]
)
event = UserRegisteredEvent(user_id=1, email="test@example.com")
system.publish(event)
Python Integration
In your code:
from domain_events import domain_events
domain_events.publish(user_event)
Celery Integration
from domain_events import DomainEventSystem
from celery import Celery
app = Celery()
event_system = DomainEventSystem(celery_app=app)
Performance
- Lookup: 40-60ns (8x faster than Django Signals)
- Dispatch (Cython): 90-120ns per handler (typically 2-10x faster than pure Python)
- Bulk dispatch (Cython): up to 10x faster for large batches
- Memory: 60% less usage compared to Django Signals
- Benchmark results:
- Cython event dispatch: ~110ns per handler (10 handlers, single event)
- Python event dispatch: ~170ns per handler (10 handlers, single event)
- Cython bulk dispatch: ~25μs for 1000 events
- Python bulk dispatch: ~88μs for 1000 events
For best results in production, always enable Cython acceleration.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_python_events-1.0.0.tar.gz.
File metadata
- Download URL: fast_python_events-1.0.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20b9454a699d4bba62dd3b9eddcfa583228abe7869bbb9f2289917af494c9d1d
|
|
| MD5 |
d337c138419bba59afbbb98bb2b98516
|
|
| BLAKE2b-256 |
0bb80d530d335afa7497ac7cd33678b11f0d6e2dfcb5cca86c91510a393ffa11
|
File details
Details for the file fast_python_events-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fast_python_events-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7b2c02935fe0110b7160f92e2e6f0d0d9dc5d992da15dc44605c16155d97d24
|
|
| MD5 |
a6370385a25706e58f077785dd33c242
|
|
| BLAKE2b-256 |
bbe20a41fa9d81df45bff09a6cb9a4821084b1a661a5bd68f236258888bb2d1f
|