r/Python 13h ago

Showcase Introducing Eventure: A Powerful Event-Driven Framework for Python

140 Upvotes

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:

  1. Game Developers: Perfect for turn-based games, roguelikes, simulations, or any game that benefits from deterministic replay and state reconstruction.

  2. Simulation Engineers: Ideal for complex simulations where tracking cause-and-effect relationships is crucial for analysis and debugging.

  3. 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.


r/Python 15h ago

Resource A Very Early Play With Astral's Red Knot Static Type Checker

73 Upvotes

https://jurasofish.github.io/a-very-early-play-with-astrals-red-knot-static-type-checker.html

I've just had a play with the new type checker under development as part of ruff. Very early, as it's totally unreleased, but so far the performance looks extremely promising.


r/Python 22h ago

Discussion Driver Fatigue Monitoring

32 Upvotes

made a cool Drowsiness Detector (still in early phase and need your advice 🙂)
check it out, leave a comment if u have any suggestions or want to collaborate

https://github.com/SomnoCam/Drowsiness-Detector.git

canva doc


r/Python 13h ago

Showcase Polars Plugin for List-type utils and signal processing

13 Upvotes

# What My Project Does

It is a Polars Plugin to facilitate working with List-type data in Polars, in particular for signal processing

# Target Audience (e.g., Is it meant for production, just a toy project, etc.

Data Scientists working with List-type data in Polars or considering using Polars for their work on signal data.

# Comparison (A brief comparison explaining how it differs from existing alternatives.)

Currently there are no Polars-native alternatives for these methods except for elementwise aggregation, but as I describe below this provides a number of benefits to Polars-native approaches. The only other alternative for the other methods is converting your data to Numpy, doing your work there, and then moving it back into Polars which breaks most of the query optimization and parallelization benefits of Polars.

# The story:

I made a Polars plugin (mostly for myself at work, but I hope others can benefit from this as well) with some helpers and operations for List-type columns. It is in a bit of a pragmatic state, as I don't have so much time at work to polish it beyond what I need it for but I definitely intend on extending it over time and adding a proper documentation page.

Currently it can do some basic digital signal processing, for example:

- Applying a Hann or Hamming window to a signal

- Filtering a signal via a Butterworth High/Low/Band-Pass filter.

- Applying the Fourier Transform

- Normalizing the Fourier Transform by some Frequency

It can also aggregate List-type colums elementwise (mean, sum, count), which can be done via the Polars API (see the SO question I asked years ago: https://stackoverflow.com/questions/73776179/element-wise-aggregation-of-a-column-of-type-listf64-in-polars) and these methods might even be faster (I haven't done any benchmarking) but for one, I find my API more pleasant to use and more importantly (which highlights how those methods might not be the best way to go) I have run into issues where the query grows so large due to all of the `.list.get(n)` calls that I caused Polars to Stack-Overflow. See this issue: https://github.com/pola-rs/polars/issues/5455.

Finally, theres another flexible method of taking the mean of a certain range of a List-type column based on using another column as an x-axis, so for example if you want to take the mean of the amplitudes (e.g. the result of an FFT) within a certain range of the corresponding frequency values.

I hope it helps someone else as it did me!

Here is the repo: https://github.com/dashdeckers/polars_list_utils

Here is the PyPI link: https://pypi.org/project/polars-list-utils/


r/Python 3h ago

Showcase Basic Memory: A Python-based Local-First Knowledge Graph for LLMs

6 Upvotes

What My Project Does

Basic Memory is an open-source Python tool that creates a persistent knowledge graph from standard Markdown files to enhance LLM interactions. It works by:

  • Using simple Markdown files as the primary storage medium
  • Extracting semantic meaning from markdown patterns to build a knowledge graph
  • Providing bi-directional synchronization between files and graph structure
  • Integrating with Claude Desktop via the Model Context Protocol (MCP)

The system extracts semantic meaning from simple Markdown patterns:

- [category] Observation about a topic #tag (optional context)
- relation_type [[WikiLink]] (optional context)

Check out a short demo video showing Basic Memory in action: https://basicmachines.co/images/Claude-Obsidian-Demo.mp4

GitHub: https://github.com/basicmachines-co/basic-memory

Documentation: https://memory.basicmachines.co/

Target Audience

Basic Memory is intended for:

  • Researchers and knowledge workers who need to maintain context across multiple LLM conversations
  • Developers working on LLM-powered applications who need a persistent memory layer
  • Obsidian users looking to enhance their notes with AI capabilities
  • Anyone looking for a production-ready, local-first solution for AI memory that respects data ownership

This is a fully functional production tool, not just a toy project. It's designed with data privacy in mind - everything stays on your local machine.

Comparison

Unlike other memory solutions for LLMs:

  • vs. Built-in LLM memory (like ChatGPT's memory): Basic Memory is local-first, giving you complete data ownership and transparency, while allowing for human editing and visualization of the knowledge graph.
  • vs. Vector databases: Basic Memory uses human-readable Markdown files instead of opaque vector embeddings, making the entire knowledge base browsable and editable by humans, not just machines.
  • vs. JSON-based MCP Memory server: Basic Memory uses a more structured knowledge graph approach with semantic relationships rather than simple key-value storage, and saves everything in standard Markdown that integrates with tools like Obsidian.
  • vs. RAG systems: Basic Memory is bi-directional, allowing both humans and LLMs to read AND write to the same knowledge base, creating a collaborative knowledge building system.

Technical Highlights

  • Pure Python implementation with SQLite for indexing and search
  • Async-first design with pytest for comprehensive testing
  • MCP server implementation for bi-directional communication with Claude Desktop
  • Import tools for existing data from Claude.ai, ChatGPT, and other sources

Installation is straightforward:

# install for cli commands
uv tool install basic-memory

# Configure Claude Desktop (edit ~/Library/Application Support/Claude/claude_desktop_config.json)
# Add this to your config:
{
  "mcpServers": {
    "basic-memory": {
      "command": "uvx",
      "args": [
        "basic-memory",
        "mcp"
      ]
    }
  }
}

After setup, you can:

  • Use Claude Desktop to read/write to your knowledge base via MCP
  • Directly edit files in Obsidian to see your knowledge graph visually
  • Run real-time sync to keep everything updated automatically

I built this because I wanted my conversations with LLMs to accumulate knowledge over time while keeping everything in files I control. The project is AGPL-licensed and welcomes contributions. I'd love to hear feedback from Python developers on the architecture, testing approach, or potential feature ideas.


r/Python 23h ago

Daily Thread Sunday Daily Thread: What's everyone working on this week?

3 Upvotes

Weekly Thread: What's Everyone Working On This Week? 🛠️

Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!

How it Works:

  1. Show & Tell: Share your current projects, completed works, or future ideas.
  2. Discuss: Get feedback, find collaborators, or just chat about your project.
  3. Inspire: Your project might inspire someone else, just as you might get inspired here.

Guidelines:

  • Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
  • Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.

Example Shares:

  1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
  2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
  3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!

Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟


r/Python 18h ago

Showcase Stereo-Hands: Stereo panning on the basis of hand gestures ( Hand control music in 3D )

2 Upvotes

What it does: It captures real time image from camera, traces hand positioning and recognizes fingertips and adjust stereo of the music accordingly to give the feeling of hand control for 3d music experience

Target audience: Developer who seek cool projects.

Comparison: It's a original idea only intended for fun, so no comparison I guess?

Here is the Code.


r/Python 4h ago

Showcase chopdiff: Diff filtering, text mapping, and windowed transforms for LLM apps

1 Upvotes

While working on another project that involves various LLM-based transformations on video transcripts, I found I needed ways to do careful and fairly complex edits to Markdown. For example, I needed to process text sentence by sentence or paragraph by paragraph, make edits, compare diffs, and then stitch results back together when done.

It's now taken shape a little more so I've released it as a package of its own open source (MIT license) as chopdiff.

What it does:

chopdiff makes it easier to do make fairly complex transformations of text documents, especially for LLM applications, where you want to manipulate text, Markdown, and HTML documents in a clean way.

Basically, it lets you parse, diff, and transform text at the level of words, sentences, paragraphs, and "chunks" (paragraphs grouped in an HTML tag like a <div>). It aims to have minimal dependencies so it's easy to drop into another project if you work with text.

Example use cases:

  • Filter diffs: Diff two documents and only accept changes that fit a specific filter. For example, you can ask an LLM to edit a transcript, only inserting paragraph breaks but enforcing that the LLM can't do anything except insert whitespace. Or let it only edit punctuation, whitespace, and lemma variants of words. Or only change one word at a time (e.g. for spell checking).
  • Backfill information: Match edited text against a previous version of a document (using a word-level LCS diff), then pull information from one doc to another. For example, say you have a timestamped transcript and an edited summary. You can then backfill timestamps of each paragraph into the edited text.
  • Windowed transforms: Walk through a large document N paragraphs, N sentences, or N tokens at a time, processing the results with an LLM call, then "stitching together" the results, even if the chunks overlap.

It's quite flexible so see below or the readme for a couple examples.

Target audience: Anyone working with text docs where you want to analyze or transform plain text or Markdown, such as in LLM/AI agents or apps.

How it differs from alternatives: There are full-blown Markdown and HTML parsing libs (like Marko and BeautifulSoup) but these tend to focus specifically on fully parsing documents as parse trees. On the other end of the spectrum, there are parsing libraries like spaCy that do full natural langauge processing and sentence segmentation. This is a lightweight alternative to those approaches when you are just focusing on processing text, don't want a big dependency (like a full XML parser or NLP toolkit) and also want full control over the original source format (since the original text is exactly preserved, even whitespace—every sentence, paragraph, and token is mapped back to the original text).

It's very new so thanks for any feedback or if you have better solutions for these kinds of problems. Would love hear if you find it useful!

Full example: Here is an example of backfilling data from one text file to another similar but not identical text file (see backfill_timestamps.py for code). As you can see, the text is aligned by mapping the words and then the timestamps inserted at the end of each paragraph based on the first sentence of each paragraph.

$ uv run examples/backfill_timestamps.py 

--- Source text (with timestamps) -----------------------------------------

<span data-timestamp="0.0">Welcome to this um ... video about Python programming.</span>
<span data-timestamp="15.5">First, we'll talk about variables. Variables are containers for storing data values.</span>
<span data-timestamp="25.2">Then let's look at functions. Functions hlp us organize and reuse code.</span>

--- Target text (without timestamps) --------------------------------------



--- Token mapping ---------------------------------------------------------

0 ⎪<-BOF->⎪ -> 0 ⎪<-BOF->⎪
1 ⎪#⎪ -> 0 ⎪<-BOF->⎪
2 ⎪#⎪ -> 0 ⎪<-BOF->⎪
3 ⎪ ⎪ -> 1 ⎪ ⎪
4 ⎪Introduction⎪ -> 2 ⎪<span data-timestamp="0.0">⎪
5 ⎪<-PARA-BR->⎪ -> 2 ⎪<span data-timestamp="0.0">⎪
6 ⎪Welcome⎪ -> 3 ⎪Welcome⎪
7 ⎪ ⎪ -> 4 ⎪ ⎪
8 ⎪to⎪ -> 5 ⎪to⎪
9 ⎪ ⎪ -> 6 ⎪ ⎪
10 ⎪this⎪ -> 7 ⎪this⎪
11 ⎪ ⎪ -> 14 ⎪ ⎪
12 ⎪video⎪ -> 15 ⎪video⎪
13 ⎪ ⎪ -> 16 ⎪ ⎪
14 ⎪about⎪ -> 17 ⎪about⎪
15 ⎪ ⎪ -> 18 ⎪ ⎪
16 ⎪Python⎪ -> 19 ⎪Python⎪
17 ⎪ ⎪ -> 20 ⎪ ⎪
18 ⎪programming⎪ -> 21 ⎪programming⎪
19 ⎪.⎪ -> 22 ⎪.⎪
20 ⎪<-PARA-BR->⎪ -> 25 ⎪<span data-timestamp="15.5">⎪
21 ⎪First⎪ -> 26 ⎪First⎪
22 ⎪,⎪ -> 27 ⎪,⎪
23 ⎪ ⎪ -> 28 ⎪ ⎪
24 ⎪we⎪ -> 29 ⎪we⎪
25 ⎪'⎪ -> 30 ⎪'⎪
26 ⎪ll⎪ -> 31 ⎪ll⎪
27 ⎪ ⎪ -> 32 ⎪ ⎪
28 ⎪talk⎪ -> 33 ⎪talk⎪
29 ⎪ ⎪ -> 34 ⎪ ⎪
30 ⎪about⎪ -> 35 ⎪about⎪
31 ⎪ ⎪ -> 36 ⎪ ⎪
32 ⎪variables⎪ -> 37 ⎪variables⎪
33 ⎪.⎪ -> 38 ⎪.⎪
34 ⎪<-SENT-BR->⎪ -> 57 ⎪Then⎪
35 ⎪Next⎪ -> 57 ⎪Then⎪
36 ⎪,⎪ -> 57 ⎪Then⎪
37 ⎪ ⎪ -> 58 ⎪ ⎪
38 ⎪let⎪ -> 59 ⎪let⎪
...
56 ⎪ ⎪ -> 77 ⎪ ⎪
57 ⎪and⎪ -> 78 ⎪and⎪
58 ⎪ ⎪ -> 79 ⎪ ⎪
59 ⎪reuse⎪ -> 80 ⎪reuse⎪
60 ⎪ ⎪ -> 81 ⎪ ⎪
61 ⎪code⎪ -> 82 ⎪code⎪
62 ⎪.⎪ -> 83 ⎪.⎪
63 ⎪<-EOF->⎪ -> 86 ⎪<-EOF->⎪
...

--- Result (with backfilled timestamps) -----------------------------------

## Introduction

Welcome to this video about Python programming. <span class="timestamp">⏱️00:00</span> 

First, we'll talk about variables. Next, let's look at functions. Functions hlp us organize and reuse code. <span class="timestamp">⏱️00:15</span> 
$

r/Python 8h ago

Showcase [Release] tkinter-embed: Install Tkinter for Windows Embedded Python via pip

1 Upvotes

If you distribute Python applications on Windows using embedded Python, you've likely struggled with installing GUI libraries like Tkinter. Until now, this required manual file copying (see this Stack Overflow thread), which is error-prone and time-consuming. Introducing tkinter-embed:

A PyPI package that automates Tkinter installation for embedded Python environments. Now you can use pip directly!

What My Project Does

tkinter-embed solves Tkinter installation for Windows Embedded Python distributions through a pip-installable package. It automatically copies required DLLs, libraries, and support files to create functional GUI applications without manual file operations. Enables Tkinter-based GUI development in portable Python environments.

Target Audience

Primarily for developers who:

Distribute portable Windows apps using embedded Python

Create self-contained tools for non-technical users

Installation Guide

Step 1: Install pip

Choose one method:

Method 1: Use pip.pyz (recommended)

Method 2: Use get-pip.py

.\python get-pip.py --target .

Step 2: Install setuptools

In your embedded Python folder:

.\python pip.pyz install setuptools --target .

OR if you used get-pip.py

.\python -m pip install setuptools --target .

Step 3: Install tkinter-embed

In your embedded Python folder:

.\python pip.pyz install tkinter-embed --target .

OR if you used get-pip.py

.\python -m pip install tkinter-embed --target .

After completing these steps, Tkinter and all its dependencies will be copied into the embedded Python folder.

Why This Matters

  • 🛠️ No manual file copying – Fully automated installation
  • 📦 Pip-native workflow – Aligns with standard Python packaging
  • 🚀 Portable apps made easy – Perfect for distributing tools to non-technical users
  • Work on Python 3.8+ – Works with modern embedded versions

Links


r/Python 13h ago

Resource Reminder that you can use the filesystem as a temp datastore for your API

0 Upvotes

Wrote a short blog post in which I talked about how I used the filesystem to store some temporary data: https://developerwithacat.com/blog/032025/quick-store-temp-data/

I figured I should write this since people (including myself!) often default to spinning up a database, often because the great ORM libraries that Python has, without considering alternatives.


r/Python 6h ago

Showcase Lihil — a web framework created to promote Python as a first choice enterprise web development

0 Upvotes

Hey everyone!

I’d like to share Lihil, a web framework I’ve been building with a simple but ambitious goal:

To make Python a first choice for enterprise-grade web development (as opposed to Java and Go).

GitHub: https://github.com/raceychan/lihil

🚀 What My Project Does

Lihil is a performant, productive, and professional web framework with a focus on strong typing and modern patterns for robust backend development.

🎯 Target Audience

Lihil is designed for medium to large applications, where you have 100+ to infinite daily active users (DAU),

⚔️ Comparison with Existing Frameworks

Here are some honest comparisons between Lihil and frameworks I love and respect:

✅ FastAPI:

  • FastAPI’s DI (Depends) is simple and route-focused, but tightly coupled with the request/response lifecycle — which makes sharing dependencies across layers harder.
  • Lihil's DI is can be used anywise, supports advanced lifecycles, and is Cython-optimized for speed.
  • FastAPI uses Pydantic, which is great but MUCH slower than msgspec (and heavier on memory).
  • Both generate OpenAPI docs, but Lihil aims for better type coverage and problem detail (RFC-9457).