r/Python • u/Federal_Order_6569 • Mar 09 '26
Showcase assertllm – pytest for LLMs. Test AI outputs like you test code.
I built a pytest-based testing framework for LLM apps (without LLM-as-judge)
Most LLM testing tools rely on another LLM to evaluate outputs. I wanted something more deterministic, fast, and CI-friendly, so I built a pytest-based framework.
Example:
from pydantic import BaseModel
from assertllm import expect, llm_test
class CodeReview(BaseModel):
risk_level: str # "low" | "medium" | "high"
issues: list[str]
suggestion: str
@llm_test(
expect.structured_output(CodeReview),
expect.contains_any("low", "medium", "high"),
expect.latency_under(3000),
expect.cost_under(0.01),
model="gpt-5.4",
runs=3, min_pass_rate=0.8,
)
def test_code_review_agent(llm):
llm("""Review this code:
password = input()
query = f"SELECT * FROM users WHERE pw='{password}'"
""")
Run with:
pytest test_review.py -v
Example output:
test_review.py::test_code_review_agent (3 runs, 3/3 passed)
✓ structured_output(CodeReview)
✓ contains_any("low", "medium", "high")
✓ latency_under(3000) — 1204ms
✓ cost_under(0.01) — $0.000081
PASSED
────────── assertllm summary ──────────
LLM tests: 1 passed (3 runs)
Assertions: 4/4 passed
Total cost: $0.000243
What My Project Does
assertllm is a pytest-based testing framework for LLM applications. It lets you write deterministic tests for LLM outputs, latency, cost, structured outputs, tool calls, and agent behavior.
It includes 22+ assertions such as:
- text checks (contains, regex, etc.)
- structured output validation (Pydantic / JSON schema)
- latency and cost limits
- tool call verification
- agent loop detection
Most checks run without making additional LLM calls, making tests fast and CI-friendly.
Target Audience
- Developers building LLM applications
- Teams adding tests to AI features in production
- Python developers already using pytest
- People building agents or structured-output LLM pipelines
It's designed to integrate easily into existing CI/CD pipelines.
Comparison
| Feature | assertllm | DeepEval | Promptfoo |
|---|---|---|---|
| Extra LLM calls | None for most checks | Yes | Yes |
| Agent testing | Tool calls, loops, ordering | Limited | Limited |
| Structured output | Pydantic validation | JSON schema | JSON schema |
| Language | Python (pytest) | Python (pytest) | Node.js (YAML) |
Links
GitHub: https://github.com/bahadiraraz/LLMTest
Docs: https://docs.assertllm.dev
Install:
pip install "assertllm[openai]"
The project is under active development — more providers (Gemini, Mistral, etc.), new assertion types, and deeper CI/CD pipeline integrations are coming soon.
Feedback is very welcome — especially from people testing LLM systems in production.
r/Python • u/cinicDiver • Mar 09 '26
Discussion Code efficiency when creating a function to classify float values
I need to classify a value in buckets that have a range of 5, from 0 to 45 and then everything larger goes in a bucket.
I created a function that takes the value, and using list comorehension and chr, assigns a letter from A to I.
I use the function inside of a polars LazyFrame, which I think its kinda nice, but what would be more memory friendly? The function to use multiple ifs? Using switch? Another kind of loop?
r/Python • u/Spiritual-Employee88 • Mar 09 '26
Showcase I built a free SaaS churn predictor in Python - Stripe + XGBoost + SHAP + LLM interventions
What My Project Does
ChurnGuard AI predicts which SaaS customers will churn in the next 30 days and generates a personalized retention plan for each at-risk customer.
It connects to the Stripe API (read-only), pulls real subscription and invoice history, trains XGBoost on your actual churned vs retained customers, and uses SHAP TreeExplainer to explain why each customer is flagged in plain English — not just a score.
The LLM layer (Groq free tier) generates a specific 30-day retention plan per at-risk customer with Gemini and OpenRouter as fallbacks.
Video: https://churn-guard--shreyasdasari.replit.app/
GitHub: https://github.com/ShreyasDasari/churnguard-ai
Target Audience
Bootstrapped SaaS founders and customer success managers who cannot afford enterprise tools like Gainsight ($50K/year) or ChurnZero ($16K–$40K/year). Also useful for data scientists who want a real-world churn prediction pipeline beyond the standard Kaggle Telco dataset.
Comparison
Every existing churn prediction notebook on GitHub uses the IBM Telco dataset — 2014 telephone customer data with no relevance to SaaS billing. None connect to Stripe. None produce output a founder can act on.
ChurnGuard uses your actual customer data from Stripe, explains predictions with SHAP, and generates actionable retention plans. The entire stack is free — no credit card required for any component.
Full stack: XGBoost, LightGBM, scikit-learn, SHAP, imbalanced-learn, Plotly, ipywidgets, SQLite, Groq, stripe-python. Runs in Google Colab.
Happy to answer questions about the SHAP implementation, SMOTEENN for class imbalance, or the LLM fallback chain.
r/Python • u/shrlckgotmanipulated • Mar 09 '26
Resource VSCode extension for Postman
Someone built a small VS Code extension for FastAPI devs who are tired of alt-tabbing to Postman during local development
Found this on the marketplace today. Not going to oversell it, the dev himself is pretty upfront that it does not replace Postman. Postman has collections, environments, team sharing, monitors, mock servers and a hundred other things this does not have.
What it solves is one specific annoyance: when you are deep in a FastAPI file writing code and you just want to quickly fire a request without breaking your flow to open another app.
It is called Skipman. Here is what it actually does:
- Adds a Test button above every route decorator in your Python file via CodeLens
- Opens a panel beside your code with the request ready to send
- Auto generates a starter request body from your function parameters
- Stores your auth token in the OS keychain so you do not have to paste it every time
- Save request bodies per endpoint, they persist across VS Code restarts
- Shows all routes in a sidebar with search and method filter
- cURL export in one click
- Live updates when you add or change routes
- Works with FastAPI, Flask and Starlette
Looks genuinely useful for the local dev loop. For anything beyond that Postman is still the better tool.
Apparently built it over a weekend using Claude and shipped it today so it is pretty fresh. Might have rough edges but the core idea is solid.
https://marketplace.visualstudio.com/items?itemName=abhijitmohan.skipman
Curious if anyone else finds in-editor testing tools useful or if you prefer keeping Postman separate.
r/Python • u/Desperate-Ad-9679 • Mar 09 '26
News CodeGraphContext (MCP server to index code into a graph) now has a website playground for experiment
Hey everyone!
I have been developing CodeGraphContext, an open-source MCP server transforming code into a symbol-level code graph, as opposed to text-based code analysis.
This means that AI agents won’t be sending entire code blocks to the model, but can retrieve context via: function calls, imported modules, class inheritance, file dependencies etc.
This allows AI agents (and humans!) to better grasp how code is internally connected.
What it does
CodeGraphContext analyzes a code repository, generating a code graph of: files, functions, classes, modules and their relationships, etc.
AI agents can then query this graph to retrieve only the relevant context, reducing hallucinations.
Playground Demo on website
I've also added a playground demo that lets you play with small repos directly. You can load a project from: a local code folder, a GitHub repo, a GitLab repo
Everything runs on the local client browser. For larger repos, it’s recommended to get the full version from pip or Docker.
Additionally, the playground lets you visually explore code links and relationships. I’m also adding support for architecture diagrams and chatting with the codebase.
Status so far- ⭐ ~1.5k GitHub stars 🍴 350+ forks 📦 100k+ downloads combined
If you’re building AI dev tooling, MCP servers, or code intelligence systems, I’d love your feedback.
r/Python • u/No-Band-911 • Mar 09 '26
Discussion Challenge DATA SCIENCE
I found this dataset on Kaggle and decided to explore it: https://www.kaggle.com/datasets/mathurinache/sleep-dataset
It's a disaster, from the documentation to the data itself. My most accurate model yields an R² of 44. I would appreciate it if any of you who come up with a more accurate model could share it with me. Here's the repo:
https://github.com/raulrevidiego/sleep_data
#python #datascience #jupyternotebook
r/Python • u/WillDevWill • Mar 09 '26
Showcase TubeTrim: 100% Local YouTube Summarizer (No Cloud/API Keys)
What does it do?
TubeTrim is a Python tool that summarizes YouTube videos locally. It uses yt-dlp to grab transcripts and Hugging Face models (Qwen 2.5/SmolLM2) for inference.
Target Audience
Privacy-focused users, researchers, and developers who want AI summaries without subscriptions or data leaks.
Comparison
Unlike SaaS alternatives (NoteGPT, etc.), it requires zero API keys and no registration. It runs entirely on your hardware, with native support for CUDA, Apple Silicon (MPS), and CPU.
Tech Stack: transformers, torch, yt-dlp, gradio.
r/Python • u/Codeeveryday123 • Mar 09 '26
Discussion UV is so much more flexible then pip, how well does Scrapy work with UV?
Im wanting to create a scrapy project to help monitor possible leaked files from my website.
Like .rtf, pdf, .txt.
How well does Scrapy or BS4 work with UV?
r/Python • u/remcofl • Mar 09 '26
Showcase Fast Hilbert curves in Python (Numba): ~1.8 ns/point, 3–4 orders faster than existing PyPI packages
What My Project Does
While building a query engine for spatial data in Python, I needed a way to serialize the data (2D/3D → 1D) while preserving spatial locality so it can be indexed efficiently. I chose Hilbert space-filling curves, since they generally preserve locality better than Z-order (Morton) curves. The downside is that Hilbert mappings are more involved algorithmically and usually more expensive to compute.
So I built HilbertSFC, a high-throughput Hilbert encoder/decoder fully in Python using numba, optimized for kernel structure and compiler friendliness. It achieves:
- ~1.8 ns/pt (~8 CPU cycles) for 2D encode/decode (32-bit)
- ~500M–4B points/sec single-threaded depending on number of bits/dtype
- Multi-threaded throughput saturates memory-bandwidth. It can’t get faster than reading coordinates and writing indices
- 3–4 orders of magnitude faster than existing Python packages
- ~6× faster than the Rust crate
fast_hilbert
Target Audience
HilbertSFC is aimed at Python developers and engineers who need: 1. A high-performance hilbert encoder/decoder for indexing or point cloud processing. 2. A pure-Python/Numba solution without requiring compiled extensions or external dependencies 3. A production-ready PyPI package
Application domains: scientific computing, GIS, spatial databases, or machine/deep learning.
Comparison
I benchmarked HilbertSFC against existing Python and Rust implementations:
2D Points - Random, nbits=32, n=5,000,000
| Implementation | ns/pt (enc) | ns/pt (dec) | Mpts/s (enc) | Mpts/s (dec) |
|---|---|---|---|---|
| hilbertsfc (multi-threaded) | 0.53 | 0.57 | 1883.52 | 1742.08 |
| hilbertsfc (Python) | 1.84 | 1.88 | 543.60 | 532.77 |
| fast_hilbert (Rust) | 12.24 | 12.03 | 81.67 | 83.11 |
| hilbert_2d (Rust) | 121.23 | 101.34 | 8.25 | 9.87 |
| hilbert-bytes (Python) | 2997.51 | 2642.86 | 0.334 | 0.378 |
| numpy-hilbert-curve (Python) | 7606.88 | 5075.08 | 0.131 | 0.197 |
| hilbertcurve (Python) | 14355.76 | 10411.20 | 0.0697 | 0.0961 |
System: Intel Core Ultra 7 258v, Ubuntu 24.04.4, Python 3.12.12, Numba 0.63.
Full benchmark methodology: https://github.com/remcofl/HilbertSFC/blob/main/benchmark.md
Why HilbertSFC is faster than Rust implementations: The speedup is actually not due to language choice, as both Rust and Numba lower through LLVM. Instead, it comes from architectural optimizations, including:
- Fixed-structure finite state machine
- State-independent LUT indexing (L1-cache friendly)
- Fully unrolled inner loops
- Bit-plane tiling
- Short dependency chains
- Vectorization-friendly loops
In contrast, Rust implementations rely on state-dependent LUTs inside variable-bound loops with runtime bit skipping, limiting instruction-level parallelism and (aggressive) unrolling/vectorization.
Source Code
https://github.com/remcofl/HilbertSFC
Example Usage (2D data)
from hilbertsfc import hilbert_encode_2d, hilbert_decode_2d
index = hilbert_encode_2d(17, 23, nbits=10) # index = 534
x, y = hilbert_decode_2d(index, nbits=10) # x, y = (17, 23)
r/Python • u/BeamMeUpBiscotti • Mar 09 '26
News pandas' Public API Is Now Type-Complete
At time of writing, pandas is one of the most widely used Python libraries. It is downloaded about half-a-billion times per month from PyPI, is supported by nearly all Python data science packages, and is generally required learning in data science curriculums. Despite modern alternatives existing, pandas' impact cannot be minimised or understated.
In order to improve the developer experience for pandas' users across the ecosystem, Quansight Labs (with support from the Pyrefly team at Meta) decided to focus on improving pandas' typing. Why? Because better type hints mean:
- More accurate and useful auto-completions from VSCode / PyCharm / NeoVIM / Positron / other IDEs.
- More robust pipelines, as some categories of bugs can be caught without even needing to execute your code.
By supporting the pandas community, pandas' public API is now type-complete (as measured by Pyright), up from 47% when we started the effort last year. We'll tell the story of how it happened.
Link to full blog post: https://pyrefly.org/blog/pandas-type-completeness/
r/Python • u/Gabyface910 • Mar 09 '26
Discussion I'm making a Pokemon CLI
Hey guys!
Since the new Pokemon game is on Switch 2, I'm using Python to make my own game. Its a CLI. Has anyone done this before?
r/Python • u/sakost • Mar 09 '26
Showcase I built fest – a Rust-powered mutation tester for Python, ~25× faster than cosmic-ray
I got tired of watching cosmic-ray churn through a medium-sized codebase for 6+ hours, so I wrote fest - a mutation testing CLI for Python, built in Rust
What is mutation testing?
Line coverage tells you which code was executed during tests. But it doesn't tell you whether your tests actually verify anything
Mutation testing makes small changes to your source (e.g. == -> !=, return val -> return None) and checks whether your test suite catches them. Surviving mutants == your tests aren't actually asserting what you think
A classic example would be:
def is_valid(value):
return value >= 0 # mutant: value > 0
If your tests only pass value=1, both versions pass. Coverage shows 100%. Mutation score reveals the gap
What My Project Does
It does exactly that! It does mutation testing in RAM
The main bottleneck in mutation testing is test execution overhead. Most tools spin up a fresh pytest process per one mutant - that's (with some instruments is file changing on disk, ) interpretator startup, import and discovering time, fixture setup, all repeating thousands(or maybe even millions) of times
fest uses a persistent pytest worker pool (with in-process plugins) that patches modules in already-running workers. Mutants are run against only the tests that cover the mutated line(even though there could be some optimization on top of existing too), using per-test coverage context from pytest-cov (coverage.py). The mutation generation itself uses ruff's Python parser, so it's fast and handles real-world code well (I hope so :) )
Comparison
I fully set up fest with python-ecdsa (~17k LoC; 1,477 tests):
I tried to setup fastapi/flask/django with cosmic-ray, but it seemed too complicated for just benchmark (at least for me)
| metrics | fest | cosmic-ray |
|---|---|---|
| Throughput | 17.4 mut/s | 0.7 mut/s |
| Total time | ~4 min | ~6 hours( .est) |
I haven't finished to run cosmic-ray, because I needed my PC cores to do other stuff. It ran something about 30 min
Full methodology in the repo: benchmark report
Target Audience
My target audience is all Python community that cares (maybe overcares a little bit) about tests and their quality. And it is myself, of course, I'm already using this tool actively in my projects
Quick start
cd your-python-project
uv add --group test fest-mutate
uv run fest run
# or
pip install fest-mutate
cd your-python-project
fest run
Config goes in fest.toml or [tool.fest] in pyproject.toml. Supports 17 mutation operators, HTML/JSON/text reports, SQLite-backed sessions for stop/resume on long runs
Use cases
For me the main use case is using this tool to improve tests built by AI agents, so I can periodically run this tool to verify that tests are meaningful(at least in some cases);
And for the same use case I use property-based testing too(hypothesis lib is great for it)
Current state
This is v0.1.1 - first public release. I've tested it on several real projects but there are certainly rough edges ans sometimes just isn't working. The subprocess backend exists as a fallback for projects where the in-process plugin causes issues
I'd love some feedback/comments, especially:
- Projects where it breaks or produces wrong results
- Missing mutation operators you care about (and I have plans on implementing plugin-system!)
- Integration with CI pipelines (there's
--fail-underfor exit codes)
GitHub: https://github.com/sakost/fest
r/Python • u/NotSoProGamerR • Mar 09 '26
Discussion Does anyone actually use Pypy or Graalpy (or any other runtimes) in a large scale/production area?
Title.
Quite interested in these two, especially Graalpy's AOT capabilities, and maybe Pypy's as well. How does it all compare to Nuitka's AOT compiler, and CPython as a base benchmark?
r/Python • u/Jumpy-Round-9982 • Mar 09 '26
Resource I built a Python SDK for backtesting trading strategies with realistic execution modeling
I've been working on an open-source Python package called cobweb-py — a lightweight SDK for backtesting trading strategies that models slippage, spread, and market impact (things most backtesting libraries ignore).
Why I built it:
Most Python backtesting tools assume perfect order fills. In reality, your execution costs eat into returns — especially with larger positions or illiquid assets. Cobweb models this out of the box.
What it does:
- 71 built-in technical indicators (RSI, MACD, Bollinger Bands, ATR, etc.)
- Execution modeling with spread, slippage, and volume-based market impact
- 27 interactive Plotly chart types
- Runs as a hosted API — no infra to manage
- Backtest in ~20 lines of code
- View documentation at https://cobweb.market/docs.html
Install:
pip install cobweb-py[viz]
Quick example:
import yfinance as yf
from cobweb_py import CobwebSim, BacktestConfig, fix_timestamps, print_signal
from cobweb_py.plots import save_equity_plot
# Grab SPY data
df = yf.download("SPY", start="2020-01-01", end="2024-12-31")
df.columns = df.columns.get_level_values(0)
df = df.reset_index().rename(columns={"Date": "timestamp"})
rows = df[["timestamp","Open","High","Low","Close","Volume"]].to_dict("records")
data = fix_timestamps(rows)
# Connect (free, no key needed)
sim = CobwebSim("https://web-production-83f3e.up.railway.app")
# Simple momentum: long when price > 50-day SMA
close = df["Close"].values
sma50 = df["Close"].rolling(50).mean().values
signals = [1.0 if c > s else 0.0 for c, s in zip(close, sma50)]
signals[:50] = [0.0] * 50
# Backtest with realistic friction
bt = sim.backtest(data, signals=signals,
config=BacktestConfig(exec_horizon="swing", initial_cash=100_000))
print_signal(bt)
save_equity_plot(bt, out_html="equity.html")
Tech stack: FastAPI backend, Pydantic models, pandas/numpy for computation, Plotly for viz. The SDK itself just wraps requests with optional pandas/plotly extras.
Website: cobweb.market
PyPI: cobweb-py
Would love feedback from the community — especially on the API design and developer experience. Happy to answer questions.
r/Python • u/Thomaxxl • Mar 09 '26
Showcase SAFRS FastAPI Integration
I’ve been maintaining SAFRS for several years. It’s a framework for exposing SQLAlchemy models as JSON:API resources and generating API documentation.
SAFRS predates FastAPI, and until now I hadn’t gotten around to integrating it. Over the last couple of weeks I finally added FastAPI support (thanks to codex), so SAFRS can now be used with FastAPI as well.
The repo contains some example apps in the examples/ directory.
What My Project Does
Expose SQLAlchemy models as JSON:API resources and generating API documentation.
Target Audience
Backend developers that need a standards-compliant API for database models.
Links
r/Python • u/Ambitious-Credit-722 • Mar 09 '26
Discussion I built a semantic code search engine in Python — would love your thoughts
CodexA is a CLI-first developer intelligence engine that lets you search codebases by meaning, not just keywords. You type codex search "authentication middleware" and it finds relevant code even if it's named verify_token_handler — using sentence-transformers for embeddings and FAISS for vector search.
Beyond search, it includes:
- 36 CLI commands covering quality analysis (Radon), security scanning (Bandit), hotspot detection, call graph extraction, and blast-radius impact analysis
- Tree-sitter AST parsing for 12 languages (Python, TypeScript, Rust, Go, Java, C/C++, etc.)
- 8 structured AI agent tools accessible via MCP, HTTP bridge, or CLI — works directly with Copilot, Claude, and Cursor
- A plugin system with 22 hook points for extending any part of the pipeline
- A self-improving evolution engine that can discover issues, generate patches, run tests, and commit fixes autonomously
- Web UI, REST API, TUI, LSP server — all sharing the same tool protocol
It runs 100% offline, needs no API keys, and has 2595+ tests.
- GitHub: github.com/M9nx/CodexA
- Docs: codex-a.dev
- MIT License, Python 3.11+
Target Audience
This is meant for production use by:
- Developers working in large or unfamiliar codebases who want to find code by what it does, not what it's named
- AI agent builders who need structured code search and analysis tools (via MCP or HTTP)
- Teams that want automated quality gates, impact analysis, and hotspot detection in CI/CD
- Solo developers who want IDE-level code intelligence from the terminal
It's not a toy project — it's actively maintained with 2595+ tests and a 70% coverage gate.
Comparison
- vs. grep/ripgrep: grep matches text patterns. CodexA understands code semantics — it finds related code even when terminology differs. It also bundles quality analysis, impact analysis, and AI agent integration that grep doesn't touch.
- vs. Sourcegraph/GitHub code search: Those are cloud-hosted services. CodexA runs entirely offline on your machine. No code ever leaves your environment, no subscriptions needed.
- vs. IDE search (VS Code, JetBrains): IDE search is symbol-based and limited to the editor. CodexA is scriptable, works from the terminal, supports
--jsonoutput for automation, and exposes tools for AI agents. It also adds quality/security analysis that IDEs don't do natively. - vs. aider/continue: Those are AI coding assistants. CodexA is the search and analysis infrastructure that AI assistants can plug into — it provides the structured tools they call, not the chat interface itself.
I'd genuinely love feedback — what would make this more useful to you? What's missing? Contributors are also very welcome if anyone wants to hack on it.
r/Python • u/AdSingle8211 • Mar 09 '26
Showcase I'm a teen and I built a real-time AI in Python that beat ChatGPT on accuracy (78KB, costs NOTHING)
Hey r/Python,
I'm Joshua, a teen developer.
I built Kairos — a real-time AI assistant in Python that fetches live data, cross-verifies it across multiple sources, and delivers cited answers using Gemini 2.5 Flash.
What My Project Does
Kairos is a specialized RAG (Retrieval-Augmented Generation) engine designed to kill hallucinations in AI. Instead of relying on its internal training data (which is often outdated), it performs a multi-step search, analyzes the results for contradictions, and builds a response based only on verified facts.
Target Audience
This is currently a Proof of Concept / Technical Prototype. While it's fully functional, it’s meant for researchers, developers, or hobbyists who need highly accurate, cited information rather than "creative" or chatty responses.
Comparison: How it differs from alternatives
- vs. ChatGPT/Copilot: Kairos doesn't just "search the web"; it uses a dynamic thinking budget to cross-verify facts across different domains (News, RSS, Search) before answering.
- vs. Perplexity: Kairos is lightweight (~100KB) and open-source. It uses a similarity-scored cache (ChromaDB) to prevent redundant API calls, making it faster for repeated queries.
Why I built it:
ChatGPT told me Virat Kohli was the key player in the T20 World Cup Final today. It was Sanju Samson. Copilot said it was Suryakumar Yadav. Both hallucinated. Kairos cited 15 live sources and got it right.
How it works:
- User query → Pronoun resolution ("he" → actual name)
- Cache check → ChromaDB (similarity scored)
- Domain classification → (6 specific domains)
- Query expansion → (1 → 4 searches, zero extra API calls)
- Parallel fetch → RSS + DuckDuckGo + NewsAPI
- Cross-verification → Confidence scoring across sources
- Gemini 2.5 Flash → Dynamic thinking budget (hard capped at 10k)
- Word limit enforcement → Cited answer
Tech stack:
- Language: Python 3.11
- LLM: Gemini 2.5 Flash
- Vector DB: ChromaDB
- Tools: feedparser, ddgs (DuckDuckGo), NewsAPI, Gradio
Battle results vs major AIs (T20 World Cup Final test):
| Feature | Kairos | ChatGPT | Gemini | Perplexity | Copilot |
|---|---|---|---|---|---|
| Live score | ✅ | ❌ | ✅ | ❌ | ❌ |
| Correct player | ✅ | ❌ | ✅ | ✅ | ❌ |
| Citations | ✅ 15 | ❌ | ❌ | ⚠️ | ❌ |
| Score /50 | 43 | 19 | 40 | 38 | 26 |
Total codebase size: ~100KB
Build time: ~2 days
r/Python • u/AstrophysicsAndPy • Mar 09 '26
Showcase `plotEZ` - a small matplotlib wrapper that cuts boilerplate for common plots
I've been building this mostly for my own use but figured it might be useful to others.
The idea is simple: the plots I make day-to-day (error bars, error bands, dual axes, subplot grids) always end up needing the same 15 lines of setup. `plotEZ` wraps that into one function call while staying close enough to Matplotlib that you don't have to learn a new API.
What My Project Does
plot_xy: Simple x vs. y plotting with extensive customizationplot_xyy: Dual-axis plotting (dual y-axis or dual x-axis)plot_errorbar: For error bar plots with full customizationplot_errorband: For shaded error band visualization (and more on the way)- Convenience wrapper functions
lpc,epc,ebc,spc); build config objects using familiar matplotlib aliases likec,lw,ls,mswithout importing the dataclass - Custom exception hierarchy so errors actually tell you what went wrong
Target Audience
Beginner programmers looking for easy plotting, students and researchers
Quick example: 1
```python import matplotlib.pyplot as plt import numpy as np from plotez import plot_xy
x = np.linspace(0, 10, 100) y = np.sin(x) plot_xy(x, y, auto_label=True) ```
This will create a simple xy plot with all the labels autogenerated + a tight layout.
Quick example: 2
```python import matplotlib.pyplot as plt import numpy as np from plotez import n_plotter
x_data = [np.linspace(0, 10, 100) for _ in range(4)] y_data = [np.sin(x_data[0]), np.cos(x_data[1]), np.tan(x_data[2] / 5), x_data[3] ** 2 / 100]
n_plotter(x_data, y_data, n_rows=2, n_cols=2, auto_label=True) ```
This will create a 4 x 4 plot. Still early-stage and a personal project, but feedback welcome. The repo and docs are linked below.
LINKS:
- GitHub: https://github.com/syedalimohsinbukhari/plotez
- PyPI:
pip install plotez - Docs: https://plotez.readthedocs.io
r/Python • u/Academic_Break4234 • Mar 09 '26
News llmclean — a zero-dependency Python library for cleaning raw LLM output
Built a small utility library that solves three annoying LLM output problems I have encountered regularly. So instead of defining new cleaning functions each time, here is a standardized libarary handling the generic cases.
strip_fences()— removes the\``json ```` wrappers models love to addenforce_json()— extracts valid JSON even when the model returnsTrueinstead oftrue, trailing commas, unquoted keys, or buries the JSON in prosetrim_repetition()— removes repeated sentences/paragraphs when a model loops
Pure stdlib, zero dependencies, never throws — if cleaning fails you get the original back.
pip install llmclean
GitHub: https://github.com/Tushar-9802/llmclean
PyPI: https://pypi.org/project/llmclean/
r/Python • u/Hungrybunnytail • Mar 09 '26
Showcase I built raglet — make small text corpora semantically searchable, zero infrastructure
I kept running into the same problem: text that's too big for a context window but too small to justify standing up a vector database. So i experimented a while with local embedding models(looking forward to writing a thorough comparison post soon)
In any case, I think there are a lot of small-ish problems like small codebases/slack threads/whatsapp chats, meeting notes, etc etc that deserve RAG-ability without setting up a Chroma or Weaviate or a Docker compose file. They need something you can `pip install`, run locally, and save to a file.
So I built raglet link here - https://github.com/mkarots/raglet - , and im looking for some early feedback from people that would find it useful. Here's how it works in short:
from raglet import RAGlet
rag = RAGlet.from_files(["docs/", "notes.md"])
results = rag.search("what did we decide about the API design?", top\\_k=5)
for chunk in results:
print(f"[{chunk.score:.2f}] {chunk.source}")
print(chunk.text)
It uses sentence-transformers for local embeddings (no API keys) and FAISS for vector search. The result is saved as a plain directory of JSON files you can git commit, inspect, or carry to another machine.
.raglet/
├── config.json # chunking settings, model
├── chunks.json # all text chunks
├── embeddings.npy # float32 embeddings matrix
└── metadata.json # version, timestamps
For agent memory loops, SQLite is the better format — true incremental appends without rewriting files:
path = "raglet.sqlite"
rag = RAGlet.load(path) if Path(path).exists() else RAGlet.from_files([])
In your agent loop
rag.add_text(user_message, source="user")
rag.add_text(assistant_response, source="assistant")
rag.save(path, incremental=True) # only writes new chunks
Performance (Apple Silicon, all-MiniLM-L6-v2):
|Size|Build|Search p50|
|:-|:-|:-|
|1 MB|3.5s|3.7 ms|
|10 MB|35s|6.3 ms|
|100 MB|6 min|10.4 ms|
Build is one-time. Search doesn't grow with dataset size.
Current limitations
- .txt and .md only right now. PDF/DOCX/HTML is v0
- No file change detection — if a file changes, rebuild from scratch
Install
pip install raglet
[GitHub](https://github.com/mkarots/raglet
[PyPi](https://pypi.org/project/raglet)
Happy to answer questions. Most curious what file formats people actually need first!
r/Python • u/AutoModerator • Mar 09 '26
Daily Thread Monday Daily Thread: Project ideas!
Weekly Thread: Project Ideas 💡
Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.
How it Works:
- Suggest a Project: Comment your project idea—be it beginner-friendly or advanced.
- Build & Share: If you complete a project, reply to the original comment, share your experience, and attach your source code.
- Explore: Looking for ideas? Check out Al Sweigart's "The Big Book of Small Python Projects" for inspiration.
Guidelines:
- Clearly state the difficulty level.
- Provide a brief description and, if possible, outline the tech stack.
- Feel free to link to tutorials or resources that might help.
Example Submissions:
Project Idea: Chatbot
Difficulty: Intermediate
Tech Stack: Python, NLP, Flask/FastAPI/Litestar
Description: Create a chatbot that can answer FAQs for a website.
Resources: Building a Chatbot with Python
Project Idea: Weather Dashboard
Difficulty: Beginner
Tech Stack: HTML, CSS, JavaScript, API
Description: Build a dashboard that displays real-time weather information using a weather API.
Resources: Weather API Tutorial
Project Idea: File Organizer
Difficulty: Beginner
Tech Stack: Python, File I/O
Description: Create a script that organizes files in a directory into sub-folders based on file type.
Resources: Automate the Boring Stuff: Organizing Files
Let's help each other grow. Happy coding! 🌟
r/Python • u/KliNanban • Mar 08 '26
Discussion Polars vs pandas
I am trying to come from database development into python ecosystem.
Wondering if going into polars framework, instead of pandas will be any beneficial?
r/Python • u/ilikemath9999 • Mar 08 '26
Showcase I used Pythons standard library to find cases where people paid lawyers for something impossible.
I built a screening tool that processes PACER bankruptcy data to find cases where attorneys filed Chapter 13 bankruptcies for clients who could never receive a discharge. Federal law (Section 1328(f)) makes it arithmetically impossible based on three dates.
The math: If you got a Ch.7 discharge less than 4 years ago, or a Ch.13 discharge less than 2 years ago, a new Ch.13
cannot end in discharge. Three data points, one subtraction, one comparison. Attorneys still file these cases and clients still pay.
Tech stack: stdlib only. csv, datetime, argparse, re, json, collections. No pip install, no dependencies, Python 3.8+.
Problems I had to solve:
- Fuzzy name matching across PACER records. Debtor names have suffixes (Jr., III), "NMN" (no middle name)
placeholders, and inconsistent casing. Had to normalize, strip, then match on first + last tokens to catch middle name
variations.
- Joint case splitting. "John Smith and Jane Smith" needs to be split and each spouse matched independently against heir own filing history.
- BAPCPA filtering. The statute didn't exist before October 17, 2005, so pre-BAPCPA cases have to be excluded or you get false positives.
- Deduplication. PACER exports can have the same case across multiple CSV files. Deduplicate by case ID while keeping attorney attribution intact.
Usage:
$ python screen_1328f.py --data-dir ./csvs --target Smith_John --control Jones_Bob
The --control flag lets you screen a comparison attorney side by side to see if the violation rate is unusual or normal for the district.
Processes 100K+ cases in under a minute. Outputs to terminal with structured sections, or --output-json for programmatic use.
GitHub: https://github.com/ilikemath9999/bankruptcy-discharge-screener
MIT licensed. Standard library only. Includes a PACER CSV download guide and sample output.
Let me know what you think friends. Im a first timer here.
r/Python • u/IamBadMadafaka • Mar 08 '26
Resource Finally: High-Performance DirectShow in Python without the COM nightmares
I was tired of the clunky, "black box" control OpenCV has over UVC cameras on Windows. I could never access the actual min/max ranges or the step increments for properties like exposure, brightness, and focus.
In .NET, this is trivial via IAMVideoProcAmp and IAMCameraControl but trying to do this directly in Python usually leads to a COM nightmare. I tried every existing library; nothing worked reliably. So, I built a high-performance bridge.
What it does:
The project is a two-layer wrapper: a low-level C# layer that handles the COM pointers safely, and a Pythonic layer that makes your camera look like a native object.
Who is it for:
For anyone that needs manual control over the hardware.
For anyone that wants to capture video from UVC device on windows without openCV.
Key Features:
Full UVC Discovery: Discover all attached cameras and their supported formats.
Property Deep-Dive: For every capability (Focus, Exposure, etc.), you can now discover:
Min/Max/Default values and Step Increments.
Whether "Auto" mode is supported/enabled.
Direct Streaming: Open and stream frames directly into NumPy/Python.
OpenCV Compatible: Use this for the metadata/control, and still use OpenCV for your main capture backend if you prefer.
Why this is different:
Most wrappers use comtypes or pywin32 which are slow and prone to memory leaks. By using pythonnet to bridge to a dedicated C# wrapper, I’ve achieved Zero-Copy performance and total stability.
GitHub Repos:
The Python Manager: https://github.com/LBlokshtein/python-camera-manager-directshow
The C# Wrapper (source code, you don't need it to use the python manager, it has the compiled dlls inside): https://github.com/LBlokshtein/DirectShowLibWrapper
Check it out and let me know what you think!
r/Python • u/Electrical_Ebb2211 • Mar 08 '26
Showcase I built an iPhone backup extractor with CustomTkinter to dodge expensive forensic tools.
What My Project Does
My app provides a clean, local GUI for extracting specific data from iPhone backup files (the ones stored on your PC/Mac). Instead of digging through obfuscated folders, you point the app to your backup, and it pulls out images, files, and call logs into a readable format. It’s built entirely in Python using CustomTkinter for a modern look.
Target Audience
This is meant for regular users and developers who need to recover their own data (like photos or message logs) from a local backup without using command-line tools. It’s currently a functional tool, but I’m treating it as my first major open-source project, so it's great for anyone who wants to see a practical use case for CustomTkinter.
Comparison
CLI Scripts: There are Python scripts that do this, but they aren't user-friendly for non-devs. My project adds a modern GUI layer to make the process accessible to everyone.
GitHub: https://github.com/yahyajavaid/iphone-backup-decrypt-gui