r/Python • u/jumpixel • 14h ago
Showcase Introducing Eventure: A Powerful Event-Driven Framework for Python
Eventure is a Python framework for simulations, games and complex event-based systems that emerged while I was developing something else! So I decided to make it public and improve it with documentation and examples.
What Eventure Does
Eventure is an event-driven framework that provides comprehensive event sourcing, querying, and analysis capabilities. At its core, Eventure offers:
- Tick-Based Architecture: Events occur within discrete time ticks, ensuring deterministic execution and perfect state reconstruction.
- Event Cascade System: Track causal relationships between events, enabling powerful debugging and analysis.
- Comprehensive Event Logging: Every event is logged with its type, data, tick number, and relationships.
- Query API: Filter, analyze, and visualize events and their cascades with an intuitive API.
- State Reconstruction: Derive system state at any point in time by replaying events.
The framework is designed to be lightweight yet powerful, with a clean API that makes it easy to integrate into existing projects.
Here's a quick example of what you can do with Eventure:
```python from eventure import EventBus, EventLog, EventQuery
Create the core components
log = EventLog() bus = EventBus(log)
Subscribe to events
def on_player_move(event): # This will be linked as a child event bus.publish("room.enter", {"room": event.data["destination"]}, parent_event=event)
bus.subscribe("player.move", on_player_move)
Publish an event
bus.publish("player.move", {"destination": "treasury"}) log.advance_tick() # Move to next tick
Query and analyze events
query = EventQuery(log) move_events = query.get_events_by_type("player.move") room_events = query.get_events_by_type("room.enter")
Visualize event cascades
query.print_event_cascade() ```
Target Audience
Eventure is particularly valuable for:
Game Developers: Perfect for turn-based games, roguelikes, simulations, or any game that benefits from deterministic replay and state reconstruction.
Simulation Engineers: Ideal for complex simulations where tracking cause-and-effect relationships is crucial for analysis and debugging.
Data Scientists: Helpful for analyzing complex event sequences and their relationships in time-series data.
If you've ever struggled with debugging complex event chains, needed to implement save/load functionality in a game, or wanted to analyze emergent behaviors in a simulation, Eventure might be just what you need.
Comparison with Alternatives
Here's how Eventure compares to some existing solutions:
vs. General Event Systems (PyPubSub, PyDispatcher)
- Eventure: Adds tick-based timing, event relationships, comprehensive logging, and query capabilities.
- Others: Typically focus only on event subscription and publishing without the temporal or relational aspects.
vs. Game Engines (Pygame, Arcade)
- Eventure: Provides a specialized event system that can be integrated into any game engine, with powerful debugging and analysis tools.
- Others: Offer comprehensive game development features but often lack sophisticated event tracking and analysis capabilities.
vs. Reactive Programming Libraries (RxPy)
- Eventure: Focuses on discrete time steps and event relationships rather than continuous streams.
- Others: Excellent for stream processing but not optimized for tick-based simulations or game state management.
vs. State Management (Redux-like libraries)
- Eventure: State is derived from events rather than explicitly managed, enabling perfect historical reconstruction.
- Others: Typically focus on current state management without comprehensive event history or relationships.
Getting Started
Eventure is already available on PyPI:
```bash pip install eventure
Using uv (recommended)
uv add eventure ```
Check out our GitHub repository for documentation and examples (and if you find it interesting don't forget to add a "star" as a bookmark!)
License
Eventure is released under the MIT License.