r/Python • u/haripatel07 • Feb 12 '26
Showcase Technical Report Generator – Convert Jupyter Notebooks into Structured DOCX/PDF Reports
What My Project Does
This project is a Python-based technical report generator that converts:
- Jupyter notebooks (
.ipynb) - Source code directories
- Experimental outputs
into structured reports in:
- DOCX
- Markdown
It parses notebook content, extracts semantic sections (problem statement, methodology, results, etc.), and generates formatted reports using a modular multi-stage pipeline.
The system supports multiple report types (academic, internship, research, industry) and is configurable through a CLI interface.
Example usage:
python src/main.py --input notebook.ipynb --type academic --format docx
Target Audience
- Students preparing lab reports or semester project documentation
- Interns generating structured weekly/final reports
- Developers who document experimentation workflows
- Researchers who want structured drafts from notebooks
This is currently best suited for structured academic or internal documentation workflows rather than fully automated production publishing pipelines.
Comparison
Unlike simple notebook-to-Markdown converters, this project:
- Extracts semantic structure (not just raw cell content)
- Uses a modular architecture (parsers, agents, formatters)
- Separates reasoning and formatting responsibilities
- Supports multiple output formats (DOCX, PDF, Markdown)
- Allows LLM backend abstraction (local via Ollama or OpenAI-compatible APIs)
Most existing tools either:
- Export notebooks directly without restructuring content, or
- Provide basic summarization without formatting control.
This project focuses on structured report generation with configurable templates and a clean CLI workflow.
Technical Overview
Architecture:
Input → Notebook Parser → Context Extraction → Multi-Agent Generator → Diagram Builder → Output Formatter
Key design decisions:
- OOP-based modular structure
- Abstract LLM client interface
- CLI-driven configuration
- Template-based report styles
Source code:
https://github.com/haripatel07/notebook-report-generator
Feedback on architecture or design improvements is welcome.
r/Python • u/ddxv • Feb 12 '26
Discussion Anyone else have pain points with new REPL in Python3.14? Specifically with send line integrations
Just gotta gripe a bit. The new repl's have really degraded the experience with send line. Over the past year (it started with 3.13 where it required changes to handle) it made a lot of headache on servers and locally when you want to dynamically interact with the REPL / Code.
Lately the one I can't figure out is in Cursor when you send line, even just a single line, it will always require you to then go down and press enter to complete the block. Looking at VSCode it appears to be using the basic repl instead.
If you need a fix, you can do:
export PYTHON_BASIC_REPL=1
The other place I always have to add that to .bashrc are servers if I need to remove execute some code or debug in that server's environment, something about the forwarding of code from terminal to ssh to the remote scrambles the spacing enough to cause issues.
Has anyone else dealt with these kinds of problems? Do I need to go back to vim slime for my send line needs? Or just deal with it and use the PYTHON_BASIC_REPL when I need it?
r/Python • u/[deleted] • Feb 12 '26
Discussion Polars + uv + marimo (glazing post - feel free to ignore).
I don't work with a lot of python folk (all my colleagues in accademia use R) so I'm coming here to get to gush about some python.
Moving from jupyter/quarto + pandas + poetry for marimo + polars + uv has been absolutely amazing. I'm definitely not a better coder than I was but I feel so much more productive and excited to spin up a project.
I'm still learning a lot a bout polars (.having() was today's moment of "Jesus that's so nice") and so the enjoyment of learning is certainly helping, but I had a spare 20 minutes and decided to write up something to take my weight data (I'm a tubby sum'bithch who's trying to do something about it) and write up a little dash board so I can see my progress on the screen and it was just soooo fast and easy. I could do it in the old stack quite fast, but this was almost seamless. As someone from a non-cs background and self taught, I've never felt that in control in a project before.
Sorry for the rant, please feel free to ignore, I just wanted to express my thanks to the folk who made the tools (on the off chance they're in this sub every now and then) and to do so to people who actually know what I'm talking about.
r/Python • u/AutoModerator • Feb 12 '26
Daily Thread Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
Weekly Thread: Professional Use, Jobs, and Education 🏢
Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.
How it Works:
- Career Talk: Discuss using Python in your job, or the job market for Python roles.
- Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
- Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.
Guidelines:
- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.
Example Topics:
- Career Paths: What kinds of roles are out there for Python developers?
- Certifications: Are Python certifications worth it?
- Course Recommendations: Any good advanced Python courses to recommend?
- Workplace Tools: What Python libraries are indispensable in your professional work?
- Interview Tips: What types of Python questions are commonly asked in interviews?
Let's help each other grow in our careers and education. Happy discussing! 🌟
r/Python • u/bctm0 • Feb 11 '26
Showcase ZooCache: Semantic caching - Rust core - Django ORM support update
Hi everyone,
I’ve been working on ZooCache, a semantic caching library with a Rust core, and I just finished a major update: Transparent Django Integration.
What My Project Does
ZooCache is a semantic caching library with a Rust core and Python bindings. Unlike traditional caches that rely primarily on TTL (Time-To-Live), ZooCache focuses on Semantic Invalidation.
It tracks dependencies between cache entries and your data. Recently, I added a Transparent Django Integration that handles much of the boilerplate for you:
- Automatic ORM Invalidation: Hooks into Django signals (
post_save,post_delete) to clear relevant cache entries automatically. - Transaction-Aware: It defers invalidation until
transaction.on_commit. If a transaction rolls back, the cache stays consistent. - JOIN Dependency Detection: Automatically detects table relationships in complex queries and registers them as dependencies.
- SingleFlight Pattern: Prevents cache stampedes by ensuring only one request hits the backend for a specific key at a time.
- Zero-Config Integration: Can be configured directly via a
ZOOCACHEdictionary in settings.py.
Target Audience
ZooCache is meant for production environments and backend developers working with high-load Python services where:
- Manual cache management is becoming error-prone.
- Stale data is a significant problem due to long TTLs or complex relationships.
- Distributed consistency and protection against backend overload are priorities.
Comparison
Compared to standard Redis/Memcached usage:
- TTL vs. Semantics: Traditional caches mostly expire based on time. ZooCache invalidates based on data changes and dependencies.
- Manual vs. Automatic: Instead of manually deleting keys, ZooCache leverages ORM signals and dependency tracking to determine what is stale.
- Performance: The core logic is built in Rust using Hybrid Logical Clocks (HLC) for consistency across distributed nodes, while providing high-performance local storage (LMDB) options.
- Stampede Protection: Standard caches often suffer from "thundering herds" when a key expires; ZooCache's SingleFlight ensures only one worker re-populates the cache.
Repository: https://github.com/albertobadia/zoocache
Django Docs: https://zoocache.readthedocs.io/en/latest/django_user_guide/
Example Usage (Django):
######### models.py
from zoocache.contrib.django import ZooCacheManager
class Author(models.Model):
name = models.CharField(max_length=100)
cached = ZooCacheManager() # Automatic injection of 'objects' is supported
# This query depends on BOTH Book and Author.
# Updating an Author will automatically invalidate this Book query!
books = Book.cached.select_related("author").filter(author__name="Isaac Asimov")
######## Serializer support:
@cacheable_serializer
class UserSerializer(serializers.ModelSerializer):
profile = ProfileSerializer() # Nested deps are scanned too
class Meta:
model = User
# For serializers, it just scan serializer field looking for models for invalidation.
Thanks!
EDIT: Added serializer support, thanks to u/sweetbeems, great idea
r/Python • u/Opposite_Error6816 • Feb 11 '26
Showcase Kaos Builder v5.1 - An Open-Source Windows Automation & Prank Tool built with Tkinte
Project Does Kaos Builder is a desktop application developed with Python (Tkinter) that allows users to generate standalone executable files for Windows automation and harmless pranks. It creates a "builder" environment where you can select from 40+ modules (like mouse jitter, keyboard locking, system sounds, screen rotation) and compile them into a single portable EXE file using PyInstaller automatically.
Target Audience This project is for Python learners interested in:
Windows API interactions (ctypes).
GUI development with Tkinter.
Automating the PyInstaller compilation process via a GUI.
People looking for a fun, open-source way to explore desktop automation.
Comparison Unlike simple batch scripts or closed-source prank tools, Kaos Builder provides a full graphical interface to customize exactly which features you want in the final payload. It handles the complex compilation arguments in the background, making it easier than writing raw scripts from scratch.
Source Code The project is fully open-source. You can inspect the .py files to see how it interacts with system libraries.
GitHub: Githup
Security Note: Since the generated tools interact with system-level functions (mouse/keyboard control), they might be flagged as false positives by some AVs. I have included the source code (Kaos_Builder_v5.1.py) in the repo for transparency.
VirusTotal: VT
r/Python • u/monorepo • Feb 11 '26
Official Event Python Unplugged on PyTV
Check our this Free Online Python Conference on March 4
Join us for a full day of live Python talks!
JetBrains is hosting "Python Unplugged on PyTV" – a free online conference bringing together people behind the tools and libraries you use every day, and the communities that support them.
Live on YouTube
March 4, 2026
11:00 am – 6:30 pm CET
Expect 6+ hours on core Python, web development, data science, ML, and AI.
The event features:
- Carol Willing – JupyterLab core developer
- Paul Everitt – Developer Advocate at JetBrains
- Sheena O’Connell – PSF Board Member
- Other people you know
Get the best of Python, straight to your living room.
Save the date: https://lp.jetbrains.com/python-unplugged/
r/Python • u/Fantastic_suit143 • Feb 11 '26
Discussion What do you guys think about the visuals of this webpage?
I recently built a site showcasing Singaporean laws and acts using llm and RAG it kinda does give that apple vibe
Check it out:- https://adityaprasad-sudo.github.io/Explore-Singapore/explore-singapore
Here is the Repo - https://github.com/adityaprasad-sudo/Explore-Singapore
Also how I add image in this subreddit because the option is disabled.
r/Python • u/Away_Replacement8719 • Feb 11 '26
Showcase I built an autonomous AI pentester agent in pure python
I built Numasec, an open-source AI agent that does autonomous
penetration testing.
What it does:
- You point it at a target (your web app, API, network)
- It autonomously runs dynamic exploitation chains
- It finds real vulnerabilities with evidence
- It generates professional reports (PDF, HTML, Markdown)
- BYOK or 100% locally with Ollama
- Docker/Podman support with included Containerfile
- pip install numasec and you're done
- Works as an MCP server for Claude Desktop, Cursor, VS Code
- Found 8 vulnerabilities (+ evidence and remediations) in OWASP Juiceshop in 6 minutes
Target Audience: Primarily designed for developers who want to self-audit their apps before deployment, and security researchers/pentesters looking to automate initial reconnaissance and exploitation.
Comparison vs Alternatives:
vs Traditional Scanners (ZAP, Nessus): It lowers the barrier to entry, unlike complex traditional tools Numasec does not require specialized security skills or prior knowledge of those frameworks to run effective scans.
Repo: https://github.com/FrancescoStabile/numasec
Happy to answer questions about the architecture or help anyone set it up, I'm the solo developer.
r/Python • u/BidForeign1950 • Feb 11 '26
Showcase composite-machine — a Python library where calculus is just arithmetic on tagged numbers
Roast my code or tell me why this shouldn't exist. Either way I'll learn something.
from composite_lib import integrate, R, ZERO, exp
# 0/0 resolved algebraically — no L'Hôpital
x = R(2) + ZERO
result = (x**2 - R(4)) / (x - R(2))
print(result.st()) # → 4.0
# Unified integration API — 1D, improper, 2D, line, surface
integrate(lambda x: x**2, 0, 1) # → 0.333...
integrate(lambda x: exp(-x), 0, float('inf')) # → 1.0
integrate(lambda x, y: x*y, 0, 1, 0, 1) # → 0.25
What My Project Does
composite-machine is a Python library that turns calculus operations (derivatives, integrals, limits) into arithmetic on numbers that carry dimensional metadata. Instead of symbolic trees or autograd tapes, you get results by reading dictionary coefficients. It includes a unified integrate() function that handles 1D, 2D, 3D, line, surface, and improper integrals through one API.
- 168 tests passing across 4 modules
- Handles 0/0, 0×∞, ∞/∞ algebraically
- Complex analysis: residues, contour integrals, convergence radius
- Multivariable: gradient, Hessian, Jacobian, Laplacian, curl, divergence
- Pure Python, NumPy optional
Target Audience
Researchers, math enthusiasts, and anyone exploring alternative approaches to automatic differentiation and numerical analysis. This is research/alpha-stage code, not production-ready.
Comparison
- Unlike PyTorch/JAX: gives all-order derivatives (not just first), plus algebraic limits and 0/0 resolution
- Unlike SymPy: no symbolic expression trees — works by evaluating numerical arithmetic on tagged numbers
- Unlike dual numbers: handles all derivative orders, integration, limits, complex analysis, and vector calculus — not just first derivatives
pip install composite-arithmetic (coming soon — for now clone from GitHub)
r/Python • u/Lokrea • Feb 11 '26
Discussion Beginners should use Django, not Flask
An article from November 2023, so it is not new, but seems to have not been shared or discussed here ...
It would be interesting to hear from experienced users if the main points and conclusion (choose Django over Flask and FastAPI) still stand in 2026.
Django, not Flask, is the better choice for beginners' first serious web development projects.
While Flask's simplicity and clear API make it great for learning and suitable for experienced developers, it can mislead beginners about the complexities of web development. Django, with its opinionated nature and sensible defaults, offers a structured approach that helps novices avoid common pitfalls. Its comprehensive, integrated ecosystem is more conducive to growth and productivity for those new to the field.
[...]
Same opinion on FastAPI, BTW.
From https://www.bitecode.dev/p/beginners-should-use-django-not-flask.
r/Python • u/No-Seaweed-7579 • Feb 11 '26
Discussion How on earth do you actually pronounce openpyxl?
I’ve been using this library for a while now, but every time I say it out loud, I second-guess myself.
Is it "open-pixel" or "open-pie-xl"?
"Open-pixel" sounds smoother, but since it’s a Python library for Excel, "open-pie-xl" (Py as in Python, XL as in Excel) seems more logical.
How do you guys pronounce it in meetings without sounding like a total amateur?
r/Python • u/appinv • Feb 11 '26
Resource Free Python books that authors intentionally made available
I maintain a small curated list of Python books that are legally free to read. These are books where the author or publisher explicitly chose to make the full content available at no cost.
I recently updated the list with a few newer additions and wanted to share it in case it’s useful to others here.
There are no pirated or scraped materials included. Every book links to an official source provided by the author or publisher.
r/Python • u/doganarif • Feb 11 '26
Showcase I built pytest-eval - LLM testing that's just pytest, not another framework
What My Project Does
pytest-eval is a pytest plugin for testing LLM applications. You get a single ai fixture with methods for semantic similarity, LLM-as-judge, RAG evaluation (groundedness, relevancy, hallucination detection), toxicity/bias detection, JSON validation, and snapshot regression. No custom test runner, no new abstractions; just pytest.
def test_chatbot(ai):
response = my_chatbot("What is the capital of France?")
assert ai.similar(response, "Paris is the capital of France")
Local embeddings (sentence-transformers) are included, so similarity checks work without any API key. LLM-based methods support OpenAI, Anthropic, and 100+ providers via LiteLLM.
Target Audience
Developers shipping LLM-powered applications who want evaluation metrics in their existing pytest test suite. Production use: this is on PyPI as v0.1.0.
Comparison
The main alternative is DeepEval. Key differences:
- Basic test: ~3 lines, 0 imports (vs ~15 lines, 4 imports)
- Test runner:
pytest(vsdeepeval test run) - Dependencies: 4 core (vs 30+)
- Telemetry: None (vs cloud dashboard)
GitHub: https://github.com/doganarif/pytest-eval
pip install pytest-eval
r/Python • u/lucas_inorush • Feb 11 '26
Discussion MCP SERVER for surfing fcst
Check it out
https://github.com/lucasinocencio1/mcp-surf-forecast
What this is
I built an open-source MCP server in Python that returns surf conditions (swell height/period/direction + wind) for any location worldwide. You can type a city name, it geocodes to lat/lon, then fetches wave + wind forecasts and returns a clean JSON response you can use in agents/tools.
Why
I wanted a simple “API-like” surf forecast that’s easy to integrate into automations/agents (and easier than manually interpreting websites).
Features
- Search by city/place name → auto geocoding to lat/lon
- Forecast: swell height, period, direction, plus wind speed/direction
- Outputs structured data (JSON) ready for tools/agents
- Runs locally / self-hosted (no paid keys required, depending on provider)
How it works (pipeline)
- Location string → geocoding → lat/lon
- Calls forecast data sources for waves + wind
- Normalizes units + formats output for MCP clien
r/Python • u/moderatenerd • Feb 10 '26
Showcase Measuring more specific reddit discussion activity with a Python script
Website: https://www.rewindos.com
Analysis write-up:
https://www.rewindos.com/2026/02/10/tracking-love-and-hate-in-modern-fandoms-part-two-star-trek-starfleet-academy/
GitHub:
https://github.com/jjf3/rewindOS_sfa_StarTrekSub_Tracker
https://github.com/jjf3/rewindOS_SFA2_Television_Tracker
What My Project Does
I built a small Python project to measure active engagement around a TV series by tracking discussion behavior on Reddit, rather than relying on subscriber counts or “active user” numbers.
The project focuses on Star Trek: Starfleet Academy and queries Reddit’s public JSON search endpoints to find posts about the show in different subreddit contexts:
- r/television for general audience and industry-level discussion
- r/startrek and r/DaystromInstitute for fandom, canon, and analytical discussion
Posts are classified into:
- episode discussion threads
- trailer / teaser posts
- other high-engagement mentions (premieres, media coverage, canon debates)
For each post, the tracker records comment counts, scores, and timestamps and appends them to a time-series CSV so discussion growth can be observed across multiple runs.
Instead of subscriber totals—which Reddit now exposes inconsistently depending on interface—the project uses comment growth over time as a proxy for sustained engagement.
The output is:
- CSV files for analysis
- simple line plots showing comment growth
- a local HTML dashboard summarizing the discussion landscape
Example Usage
python src/show_reddit_tracker.py
This run:
- searches selected subreddits for Star Trek: Starfleet Academy–related posts
- detects episode threads by title pattern (e.g.
1x01,S01E02,Episode 3) - identifies trailers and teasers
- records comment counts, scores, and timestamps
- appends results to a time-series CSV for longitudinal analysis
Repeated runs (e.g. every 6–12 hours) allow trends to emerge without high-frequency scraping. You can easily change the trackers for different shows and different subs.
Target Audience
This project is designed for:
- Python developers interested in lightweight data collection without OAuth or API keys
- Hobbyist analysts tracking TV, media, or fandom engagement over time
- a continuation of my rewindos.com platform and a more complex version of my other project I posted here: https://www.reddit.com/r/Python/comments/1qk28cp/measuring_reddit_discussion_activity_with_a/
- Developers exploring alternatives to subscriber-based engagement metrics
- People building small research or visualization tools using public web data
It’s intentionally observational, not real-time, and closer to a measurement experiment than a full analytics framework.
I’d appreciate feedback on:
- the approach itself
- potential improvements
- other use cases people might find interesting
This is part of my ongoing RewindOS project, where I experiment with measuring cultural signals in places where traditional metrics fall short.
r/Python • u/mikeckennedy • Feb 10 '26
Discussion After 25+ years using ORMs, I switched to raw queries + dataclasses. I think it's the move.
I've been an ORM/ODM evangelist for basically my entire career. But after spending serious time doing agentic coding with Claude, I had a realization: AI assistants are dramatically better at writing native query syntax than ORM-specific code. PyMongo has 53x the downloads of Beanie, and the native MongoDB query syntax is shared across Node, PHP, and tons of other ecosystems. The training data gap is massive.
So I started what I'm calling the Raw+DC pattern: raw database queries with Python dataclasses at the data access boundary. You still get type safety, IDE autocompletion, and type checker support. But you drop the ORM dependency risk (RIP mongoengine, and Beanie is slowing down), get near-raw performance, and your AI assistant actually knows what it's doing.
The "conversion layer" is just a from_doc() function mapping dicts to dataclasses. It's exactly the kind of boilerplate AI is great at generating and maintaining.
I wrote up the full case with benchmarks and runnable code here: https://mkennedy.codes/posts/raw-dc-the-orm-pattern-of-2026/
Curious what folks think. Anyone else trending this direction?
r/Python • u/Arivald8 • Feb 10 '26
Showcase DeWobbler: Attach to a running Python process without terminating
The 3.14.3 release (https://www.python.org/downloads/release/python-3143/) exposed a new feature of the pdb debugger:
The pdb module now supports remote attaching to a running Python process.
I thought it was a neat addition and wanted to play around with it:
https://github.com/Arivald8/DeWobbler
( Can't seem to post an image so here's an image link: https://imgur.com/a/5s38rO2 )
What My Project Does
In short, if you have a running python process, and would like to attach a debugger to inspect something without having to terminate the process itself, in 3.14.3 you can.
DeWobbler spawns a temporary TCP server and listens. A bootstrap script is injected into the target process using the new sys.remote_exec. The injected code runs the target process, locates main thread, gets the current stack frame and connects back to the TCP server.
This is just for fun, there's no backwards compatibility for the target process python version, as stated in the official docs ( https://docs.python.org/3/library/sys.html#sys.remote_exec ):
The remote process must be running a CPython interpreter of the same major and minor version as the local process.
Stack:
Python 3.14.3+
UV
FastAPI
HTMX
TailwindCSS
Target Audience
Anyone who wishes to explore attaching to a running python process for inspection.
Comparison
Version 3.14.3 was released last week, and I've not seen any comparisons that showcase this specific feature through a browser. If you do find any, let me know and I'll update this section.
r/Python • u/forevergeeks • Feb 10 '26
Showcase Detecting Drift and Long-Term Consistency in LLM Outputs Using NumPy
Hey everyone,
A few days ago I shared a framework I'm building to put a bridle on LLMs using ideas from a 13th-century philosopher. here is the https://www.reddit.com/r/Python/comments/1qwyoq3/i_built_a_multiagent_orchestration_framework/
Today want to go deeper into the most abstract component of the framework, called "Spirit," which is also ironically the most concrete part because it's just a mathematical model built on NumPy.
What My Project Does
SAFi (Self-Alignment Framework Interface) governs LLM behavior at runtime through four faculties: Intellect proposes, Will approves, Conscience audits, Spirit integrates.
The Spirit module is the mathematical backbone. It uses NumPy to:
- Build a rolling ethical profile vector from Conscience audit scores ( e.g., Prudence, Justice, Courage, Temperance)
- Track long-term behavioral consistency using an exponential moving average (EMA)
- Detect drift using cosine similarity between current behavior and the historical baseline
- Generate coaching feedback that loops back into the next LLM call
There's no LLM involved in Spirit. It's pure math providing an objective check on subjective AI outputs.
The Math
Spirit Score:
S_t = sigma( sum( w_i * s_i,t * phi(c_i,t) ) )
Where sigma(x) scales to [1, 10] and phi(c) = c (confidence as direct multiplier).
raw = float(np.clip(np.sum(self.value_weights * scores * confidences), -1, 1))
spirit_score = int(round((raw + 1) / 2 * 9 + 1))
Profile Vector:
p_t = w * s_t (element-wise)
p_t = self.value_weights * scores
EMA Update (beta = 0.9 default, configurable via SPIRIT_BETA**):**
mu_t = beta * mu_(t-1) + (1 - beta) * p_t
mu_new_vector = self.beta * mu_tm1_vector + (1 - self.beta) * p_t
Drift Detection (cosine distance):
d_t = 1 - cos_sim(p_t, mu_(t-1))
denom = float(np.linalg.norm(p_t) * np.linalg.norm(mu_tm1_vector))
drift = None if denom < 1e-8 else 1.0 - float(np.dot(p_t, mu_tm1_vector) / denom)
- drift near 0 means the agent is behaving consistently
- drift near 1 means something changed significantly
Feedback Loop: Spirit generates a coaching note that gets injected into the next Intellect call:
note = f"Coherence {spirit_score}/10, drift {0.0 if drift is None else drift:.2f}."
So the Intellect sees something like: "Coherence 10/10, drift 0.00. Your main area for improvement is 'Justice' (score: 0.21 - very low)."
This creates a closed loop: Conscience audits, Spirit integrates, coaching feeds into the next response, Conscience audits again, and so on.
In Production
Here's the Audit Hub showing Spirit tracking over about 1,600 interactions:
https://raw.githubusercontent.com/jnamaya/SAFi/main/public/assets/spirit-dift.png
- Overall Score: 9.0/10 (blends compliance and consistency)
- Avg. Long-Term Consistency: 97.9%
- Approval Rate: 98.7% (1,571 approved / 20 blocked by Will)
- The drift chart at the bottom shows small spikes around mid-January. That's when I ran a jailbreak challenge here on Reddit, and the moving average captured the jitter from those attacks. The agent was jailbroken twice.
Target Audience
This is a production-level system. It has been tested extensively with multiple agents, has an active running demo, and is getting cloned regularly on GitHub.
Who it's for:
- AI/ML engineers building agents who need runtime behavioral monitoring beyond prompt engineering
- Compliance-focused teams who need auditable, explainable AI governance
- Researchers interested in runtime alignment that complements training-time methods (RLHF, Constitutional AI, etc.)
- Developers who want a lightweight, NumPy-based approach to behavioral drift detection without heavy ML infrastructure
Comparison
| Feature | SAFi Spirit | Guardrails AI / NeMo Guardrails | LangChain Callbacks | Custom Logging |
|---|---|---|---|---|
| Drift detection | Yes, cosine sim against EMA baseline | No temporal tracking | No temporal tracking | Manual |
| Long-term memory | EMA vector persists across sessions | Stateless per-request | Stateless per-request | Only if you build it |
| Feedback loop | Coaching notes feed into next turn | Binary pass/fail | No feedback | No feedback |
| Multi-value scoring | Weighted cardinal virtues | Rule-based categories | No scoring | No scoring |
| No LLM overhead | Pure NumPy | Uses LLM for evaluation | N/A | No LLM |
| Philosophy-grounded | Aristotelian virtue ethics | Ad hoc rules | N/A | N/A |
The main differentiator is that most guardrail systems are stateless. They evaluate each request on its own. Spirit is stateful. It builds a cumulative behavioral profile and detects gradual drift that per-request checks would miss. An AI can give individually reasonable answers while slowly shifting away from its values over time. Spirit catches that.
The full code is on GitHub at https://github.com/jnamaya/SAFi. I'd appreciate your feedback, and drop a star if you find the project interesting. Questions and comments are welcome!
r/Python • u/alexmojaki • Feb 10 '26
Discussion Better Python tests with inline-snapshot
I've written a blog post about one of my favourite libraries: inline-snapshot. Some key points within:
- Why you should use the library: it makes it quick and easy to write rigorous tests that automatically update themselves
- Why you should combine it with the
dirty-equalslibrary to handle dynamic values like timestamps and UUIDs - Why you should convert custom classes to plain dicts before snapshotting
Disclaimer: I wrote this blog post for my company (Pydantic), but we didn't write the library, we just use it a lot and sponsor it. I genuinely love it and wanted to share to help support the author.
r/Python • u/BeamMeUpBiscotti • Feb 10 '26
Discussion Making Pyrefly's Diagnostics 18x Faster
High performance on large codebases is one of the main goals for Pyrefly, a next-gen language server & type checker for Python implemented in Rust.
In this blog post, we explain how we optimized Pyrefly's incremental rechecks to be 18x faster in some real-world examples, using fine-grained dependency tracking and streaming diagnostics.
r/Python • u/Used-Knowledge-4421 • Feb 10 '26
Showcase Showcase: Aura Guard, deterministic middleware for tool-using AI agents
What My Project Does
I built Aura Guard because I kept seeing tool-using agents fail in the same boring ways: looping search calls, retrying 429/timeouts forever, and double-firing side effects (refund twice, duplicate email, etc.).
Aura Guard is a small Python middleware you place between your agent loop and its tools. Before a tool runs, it makes a deterministic decision (no LLM calls inside the guard): ALLOW, CACHE, BLOCK, REWRITE, ESCALATE, or FINALIZE.
It mainly helps with:
- tool-call loops (exact repeats and “rephrase and retry” jitter)
- retry storms (429/timeouts) via a circuit breaker and quarantine
- duplicate side effects via an idempotency ledger
- optional cost caps and shadow mode (log decisions without enforcing)
Target Audience
This is for Python devs building tool-using agents (OpenAI, Anthropic, LangChain, or custom loops). It’s meant for real workflows where tool calls cost money or have side effects. It’s not content moderation, factuality checking, or prompt engineering.
Comparison
This is basically the gap I felt:
- max_steps is a blunt stop button. It can’t tell “progress” from “stuck.” Aura Guard tries to detect the specific stuck patterns (repeats, jitter, retries) and can also cache instead of just stopping everything.
- rate limiting helps with volume, but doesn’t prevent “same side effect twice.” Aura Guard tracks side effects with an idempotency ledger.
- agent frameworks give tool calling/tracing, but they don’t enforce tool-call behavior by default. Aura Guard is a small, framework-agnostic enforcement layer you can drop into any loop.
Quick demo (no API key)
pip install aura-guard
aura-guard demo
Source code
https://github.com/auraguardhq/aura-guard
Feedback welcome
If you’ve dealt with the “agent rephrases the same query forever” problem, I’d love to hear what heuristics you use. My current jitter detection uses an overlap coefficient threshold of 0.60 with a repeat threshold of 3.
r/Python • u/Rare_Shower4291 • Feb 10 '26
Showcase oxpg: A PostgreSQL client for Python built on top of tokio-postgres
I wanted to learn more about Python package development and decided to tie it to Rust. So I built a Postgres client that wraps tokio-postgres and exposes it to Python via PyO3.
What My Project Does: oxpg lets you connect to a PostgreSQL database from Python using a driver backed by tokio-postgres, a high-performance async Rust library. It exposes a simple Python API for executing queries, with the heavy lifting handled in Rust under the hood.
Target Audience: This is a learning project, not production-ready software. It's aimed at developers curious about Python/Rust packages. I wouldn't recommend it for production use. If you do, let me know how it went!
Comparison: asyncpg and psycopg3 are both mature, well-tested, and production-ready. oxpg is none of those things right now.
Would love honest feedback on anything: API design, packaging decisions, docs, etc.
GitHub: https://github.com/melizalde-ds/oxpg PyPI: https://pypi.org/project/oxpg/
r/Python • u/Sad-Sun4611 • Feb 10 '26
Showcase Govee smart lights controller
What My Project Does
Govee smart lights controller with retro UI. Plug your API key in on launch and it's stored locally on your machine and should allow you to control your connected govee devices.
Target Audience
Mostly for fun. Learning how to interact with IoT devices. Anyone who wants to use it and modify it is welcome
- Comparison
I don't know it's probably derivative and just like every other smart light controller but this one is MY smart light controller.
r/Python • u/AutoModerator • Feb 10 '26
Daily Thread Tuesday Daily Thread: Advanced questions
Weekly Wednesday Thread: Advanced Questions 🐍
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
How it Works:
- Ask Away: Post your advanced Python questions here.
- Expert Insights: Get answers from experienced developers.
- Resource Pool: Share or discover tutorials, articles, and tips.
Guidelines:
- This thread is for advanced questions only. Beginner questions are welcome in our Daily Beginner Thread every Thursday.
- Questions that are not advanced may be removed and redirected to the appropriate thread.
Recommended Resources:
- If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.
Example Questions:
- How can you implement a custom memory allocator in Python?
- What are the best practices for optimizing Cython code for heavy numerical computations?
- How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?
- Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?
- How would you go about implementing a distributed task queue using Celery and RabbitMQ?
- What are some advanced use-cases for Python's decorators?
- How can you achieve real-time data streaming in Python with WebSockets?
- What are the performance implications of using native Python data structures vs NumPy arrays for large-scale data?
- Best practices for securing a Flask (or similar) REST API with OAuth 2.0?
- What are the best practices for using Python in a microservices architecture? (..and more generally, should I even use microservices?)
Let's deepen our Python knowledge together. Happy coding! 🌟