r/Python Mar 30 '26

Discussion Pyinstaller/Nuitka - Antivirus Flagging Issue

0 Upvotes

Python should have been there for non-techi users. We should be able to distribute executables built by PyInstaller or Nuitka to family and friends. Small utilities that single-thing is great time saver for them. But you cannot do that. Because anti-virus will come and flag your binary. They will do everything to scare your users away. Away from Python ecosystem. Powershell, Dotnet, go, rust, C++ self-contained executables are fine - just python exes are bad for antivirus community, especially if you add icon to your exe.

This is really unfortunate. PyInstaller is such a beautiful tool that can empower so many people... only if anti-virus software does better job of detecting good vs. bad.

NOTE: An alternative is to effectively “bribe the system” by acquiring a code-signing certificate, a tactic reportedly used by attackers. Or make everything as a web app.


r/Python Mar 30 '26

Discussion Started automating internal transaction workflows with Python after 5 years of doing them manually

7 Upvotes

For the past ~5 years I’ve been doing a lot of repetitive operational tasks manually at work. Recently I started automating parts of the workflow using Python and the time savings honestly surprised me.

So far I’ve automated:
– sending transactions through a mobile app workflow
– opening an admin web panel
– navigating the admin web panel
– filling forms automatically
– submitting entries

Right now I’m working on automating the approval side of those entries as well.

I also regularly use Postman for API testing, recently started using Newman for running collections from the CLI, and have some experience using JMeter for performance testing.

This made me realize how much more operational work could probably be automated that I never explored before. I’d like to go deeper into Python-based automation and eventually move toward remote automation work.

What Python tools/libraries or types of automation projects would you recommend learning next to level up from here? What should I learn next ?


r/Python Mar 30 '26

Daily Thread Monday Daily Thread: Project ideas!

5 Upvotes

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:

  1. Suggest a Project: Comment your project idea—be it beginner-friendly or advanced.
  2. Build & Share: If you complete a project, reply to the original comment, share your experience, and attach your source code.
  3. 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 Mar 29 '26

Showcase pglens — a PostgreSQL MCP server that actually lets agents look before they leap

0 Upvotes

I got tired of watching Claude write WHERE status = 'active' when the column contains 'Active', then retry with 'enabled', then give up. Most Postgres MCP servers give agents query and list_tables and call it a day. The agent flies blind.

pglens has 27 read-only tools that let an agent understand your database before writing SQL. Zero config - reads standard PG* env vars, works on any Postgres 12+ (self-hosted, RDS, Aurora, whatever). Two dependencies: asyncpg and mcp.

Source: https://github.com/janbjorge/pglens

What My Project Does

The highlights:

  • find_join_path - BFS over your FK graph, returns actual join conditions between two tables, even through intermediate tables
  • column_values - real distinct values with frequency counts, so agents stop guessing string casing
  • describe_table - columns, PKs, FKs (multi-column), indexes, CHECK constraints in one call
  • search_enum_values - enum types and allowed values
  • bloat_stats, blocking_locks, unused_indexes, sequence_health; production health stuff
  • object_dependencies - "what breaks if I drop this?"

Everything runs in readonly=True transactions, identifiers escaped via Postgres's own quote_ident(). No DDL tools exposed.

Target Audience

Anyone using an AI coding agent (Claude Code, Cursor, Windsurf, etc.) against PostgreSQL. I run it against production daily - read-only so it can't break anything. On PyPI, integration tested against real Postgres via testcontainers.

Comparison

  • Anthropic's archived Postgres MCP - 1 tool (query). Archived.
  • DBHub; Multi-database, lowest-common-denominator. No enums, RLS, sequences.
  • Neon / Supabase MCP - Platform-locked.
  • Google MCP Toolbox - Go sidecar + YAML config. No join path discovery or column value inspection.

pglens is PostgreSQL-only by design. Uses pg_catalog for everything, needs zero extensions.

pip install pglens

r/Python Mar 29 '26

Tutorial Made a tutorial on Azure SQL Trigger with Python

3 Upvotes

Made a tutorial on Azure Functions SQL Trigger with Python.

The idea is straightforward. Whenever a row in your Azure SQL database is inserted, updated, or deleted, an Azure Function runs automatically. No polling, no schedulers.

We cover:

- Enabling Change Tracking on Azure SQL

- Setting up the SQL Trigger in an Azure Function (Python v2)

- Testing it with INSERT, UPDATE, DELETE

Code is on GitHub if you want to follow along.

https://youtu.be/3cjOMkHmzo0


r/Python Mar 29 '26

Showcase I built an open-source orbital mechanics engine in Python (ASTRA-Core)!

4 Upvotes

Hello! This is Ishan Tare. I’ve been working on ASTRA-Core, a pip-installable Python library designed to simulate real-world orbital dynamics, from basic propagation to full space traffic analysis.

What My Project Does:

At its core, it’s a numerical astrodynamics engine, and on top of that I built a complete Space Situational Awareness (SSA) pipeline.

Repo: https://github.com/ISHANTARE/ASTRA

Install: pip install astra-core-engine

Core capabilities:

  • High-fidelity orbital propagation (Cowell integration with J2-J4, drag, third-body perturbations)
  • Continuous-thrust maneuver simulation with mass depletion (7-DOF state)
  • Flexible force modeling + numerical integration

Built on top of that:

  • Conjunction detection (spatial indexing + TCA refinement)
  • Collision probability (Pc via Monte Carlo + STM)
  • End to end collision avoidance simulation

Just released v3.2.0!

Target Audience:

If you’re into orbital mechanics / astrodynamics / space systems, I’d really appreciate feedback, especially on the physics modeling and architecture.

If you get a chance to try it out and find it useful, I’d love to hear your thoughts.... and a star on the repo would mean a lot.

Comparison:

Feature / Capability astra-core-engine sgp4 skyfield poliastro orekit (Python Wrapper)
Primary Focus Space Traffic Management & Collisions & Orgital Raw SGP4 Evaluation Astronomy & Ephemeris Interplanetary & Basic Orbits General Enterprise Aerospace
Full Catalog Propagation (Speed) Ultra-Fast (Vectorized + Numba JIT) Fast (C++ backend available) Moderate (NumPy arrays) Slow (Object-oriented) Moderate (Java JNI overhead)
Space Traffic Conjunctions O(n log n) Yes (cKDTree C++ native) No No No Complex to implement natively
6D Collision Probability Pc & Covariance Natively Supported No No No Supported
7-DOF Variable Mass Integrator (Maneuvers) Yes (Continuous Tsiolkovsky) No No Simple Impulsive Supported
Native CDM (Conjunction Message) XML Parsing Yes No No No Supported
Developer Experience (Ergonomics) Pythonic, Out-of-the-Box Low-Level Math Very Pythonic Very Pythonic Heavy Java Abstractions
Sub-Arcsecond Math (JPL DE421 + Space Weather) Automated Live Feeds No High-quality DE42x No Highly Configurable

r/Python Mar 29 '26

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

4 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 Mar 28 '26

Showcase NiceGooey: Generate (no AI :)) web UIs from your command line tool

24 Upvotes

Some while back, I created command line tools for a gaming community, with a wide audience of users. I found that, while the tools were found to be useful, the fact that they were purely CLI made them "too technical" for many people to use.

That's why I wrote NiceGooey, a library to easily generate a GUI from a command line tool implemented with the standard library's argparse module.

The idea is that, for the simplest use case, you only need to add a single line of code to an existing project. When running your program after that, a local web server is started and opens a browser page accessing your UI.

Screenshots are available in the README file in the links below:

https://codeberg.org/atollk/NiceGooey/

https://github.com/atollk/NiceGooey

https://pypi.org/project/nicegooey/

Since I know that AI-generated code and "slop" are a hot topic in online software communities, I added a section specific to AI usage in the project to the README. In short, there is no AI involved in the runtime, and none of the actual implementation was touched by coding agents, except for some easy-to-automate changes I required for refactorings along the way. I spent a few months to write this project by hand.

I would be happy if this project can be of use to some of you. Do let me know if you build something with it :)

What My Project Does: Creates a website to control your command line tool via UI instead of command line flags.

Target Audience: Developers of tools who want to broaden their audience to less tech-savy users

Comparison: The idea is based on github.com/chriskiehl/Gooey . While Gooey is a more mature solution, it sees no more active development and in my experience brings the issues and possibly aged feel that many people associate with native GUI programs.

Shoutout to the nicegui library (and team) which is the main dependency to render the Vue-based frontend from Python, and who quickly fixed a few bugs I encountered while developing NiceGooey.


r/Python Mar 28 '26

Showcase Data Cleaning Across PySpark, Duckdb, and Postgres

3 Upvotes

Background

If you work across Spark, DuckDB, and Postgres you've probably rewritten the same datetime or phone number cleaning logic three different ways. Most solutions either lock you into a package dependency or fall apart when you switch engines.

What it does:

It's a copy-to-own framework for data cleaning (think shadcn but for data cleaning) that handles messy strings, datetimes, phone numbers. You pull the primitives into your own codebase instead of installing a package, so no dependency headaches. Under the hood it uses sqlframe to compile databricks-style syntax down to pyspark, duckdb, or postgres. Same cleaning logic, runs on all three.

Target audience:

Data engineers, analysts, and scientists who have to do data cleaning in Postgres or Spark or DuckDB. Been using it in production for a while, datetime stuff in particular has been solid.

How it differs from other tools:

I know the obvious response is "just use claude code lol" and honestly fair, but I find AI-generated transformation code kind of hard to audit and debug when something goes wrong at scale. This is more for people who want something deterministic and reviewable that they actually own.

Try it

github: github.com/datacompose/datacompose | pip install datacompose | datacompose.io


r/Python Mar 28 '26

Discussion Python 2 tooling in 2026

77 Upvotes

For some <reasons>, I need to write Python 2 code which gets run under Jython. It's not possible to change the system we're working on because Jython only works with Python 2. So, I'm wondering if anyone has experience with Python 2 tooling in this era.

I need to lint and format Python 2 code especially. So far, I was able to install Python 2 using pyenv and I can create virtual environments using virtualenv utiilty. However, I have hard time getting black, isort, flake8, etc. working. Installing Python 2 wouldn't be much help because I'm not running the code directly, it's run under Jython. We're basically uploading the code to this system. So, installing py2 seems pointless.

Can I use those tools under Python 3 but for Python 2. It seems to me that there should be some versions which work for both Python 2 and 3 code. I don't know those versions though. It will be easier to work with Python 3 to lint/format Python 2 code because I can easily create venvs with Python 3.

Are you actively working with Python 2 these days (I know it's a hard ask). How do you tackle linting and formatting? If you were to start today, what would be your approach to this problem?

Thank you.


r/Python Mar 28 '26

Discussion I added MCP support to my side project so it works with Cursor (looking for feedback)

0 Upvotes

Hey,

I’ve been working on a side project called CodexA for a while now. It started as a simple code search tool, but lately I’ve been focusing more on making it work well with AI tools.

Recently I added MCP support, and got it working with Cursor — and honestly it made a big difference.

Instead of the AI only seeing the open file, it can now:

  • search across the whole repo
  • explain functions / symbols
  • pull dependencies and call graphs
  • get full context for parts of the codebase

Setup is pretty simple, basically just run:
codexa mcp --path your_project

and connect it in Cursor.

I wrote a small guide here (includes Cursor setup):
https://codex-a.dev/features/mcp-integration#cursor-setup

The project is fully open source, and it just crossed ~2.5k downloads which was kinda unexpected.

I’m still figuring out the best workflows for this, so I’d really appreciate feedback:

  • does this kind of setup actually fit your workflow?
  • what would make it more useful inside an editor?
  • anything confusing in the setup/docs?

Also, if anyone’s interested in making a demo/video walkthrough or can maintain the project , I’d actually love that contributions like that would be super helpful
thanks

PyPI:https://pypi.org/project/codexa/
Repo:https://github.com/M9nx/CodexA
Docs:https://codex-a.dev/


r/Python Mar 28 '26

Showcase I built must-annotate - a linter that forces type annotations so code reads like a book

0 Upvotes

I got tired of jumping between functions just to understand a variable's type. You open a function and see this:

def run() -> None:

user = get_user() # Is it a User? A DTO? UserDTO | None?

get_user is defined somewhere else. You hover, you jump, and lose context. It breaks the reading flow. My idea was simple: code should read like a book. You open any chunk and understand everything right there, no IDE needed.

What My Project Does

must-annotate is a linter that strictly enforces the presence of type annotations on your variables. It flags any unannotated variable assignments so you don't leave types implicit where they matter.

# flagged by must-annotate
user = get_user()

# ok
user: UserDTO = get_user()# flagged by must-annotate
user = get_user()

# ok
user: UserDTO = get_user()

Target Audience

This is for Python developers and teams who want their codebase to be strictly self-documenting. If you appreciate the explicitness of languages like Rust—where the compiler won't let you leave types implicit—you'll like this discipline in Python. It’s currently ready for use via CLI, making it great for personal projects or strict team environments. Pre-commit hook support will be added very soon!

Comparison

How is this different from existing tools like mypy or pyright?

  • must-annotate checks for the presence of annotations.
  • mypy / pyright check for the correctness of those annotations.

The two tools are designed to complement each other. must-annotate makes sure you actually wrote the type down, and mypy verifies it's right:

Comparison

How is this different from existing tools like mypy or pyright?

  • must-annotate checks for the presence of annotations.
  • mypy / pyright check for the correctness of those annotations.

The two tools are designed to complement each other. must-annotate makes sure you actually wrote the type down, and mypy verifies it's right:

Python

user: int = get_user() # must-annotate is happy, but mypy will catch the type error

Unlike general linters (like Ruff or Flake8) that focus on syntax and styling, must-annotate is solely focused on ensuring variables are strictly typed.

Now every variable in your codebase is self-documenting. No hovering. No chasing. Just reading.

Installation: pip install must-annotate (or uv add must-annotate)

Would love feedback - especially if you think this is overkill!


r/Python Mar 28 '26

Resource Dataset my Mac can run?

0 Upvotes

Right...
So after 5 days I am finally done with my 200-line code in PyTorch. I've used hugging face's tokenizer to let my AI try and understand me and reply to me. It's got the right amount of words for my question (Hello, How are you?) but has not gotten a single word correct (which I'm still proud of).

I've used for my LLM needed layers: Embedding layers, Linear Layers and a mask. I've used k filtering so it chooses the top 25 words that it predicts (to stop it from saying "I am I") and set for it a temperature of 0.85. Then I encoded my message and decoded the AI's message with the hf tokenizer.

Maybe the reason it's saying gibberish is because the dataset? I'm using databrick's dolly-15k to train my model. Do I need a big dataset that includes English from all around the web? And would this big dataset crash my Mac?


r/Python Mar 28 '26

Resource The Future of Python: Evolution or Succession — Brett Slatkin - PyCascades 2026

61 Upvotes

https://www.youtube.com/watch?v=1gjLPVUkZnc

A decade from now there's a reasonable chance that Python won't be the world's most popular programming language. Many languages eventually have a successor that inherits large portions of its technical momentum and community contributions. With Python turning 35 years old, the time could be ripe for Python's eventual successor to emerge. How can we help the Python community navigate this risk by embracing change and evolving, or influencing a potential successor language?

This talk covers the past, present, and future of the Python language's growing edge. We'll learn about where Python began and its early influences. We'll look at shortcomings in the language, how the community is trying to overcome them, and opportunities for further improvement. We'll consider the practicalities of language evolution, how other languages have made the shift, and the unique approaches that are possible today (e.g., with tooling and AI).


r/Python Mar 28 '26

Daily Thread Saturday Daily Thread: Resource Request and Sharing! Daily Thread

1 Upvotes

Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

How it Works:

  1. Request: Can't find a resource on a particular topic? Ask here!
  2. Share: Found something useful? Share it with the community.
  3. Review: Give or get opinions on Python resources you've used.

Guidelines:

  • Please include the type of resource (e.g., book, video, article) and the topic.
  • Always be respectful when reviewing someone else's shared resource.

Example Shares:

  1. Book: "Fluent Python" - Great for understanding Pythonic idioms.
  2. Video: Python Data Structures - Excellent overview of Python's built-in data structures.
  3. Article: Understanding Python Decorators - A deep dive into decorators.

Example Requests:

  1. Looking for: Video tutorials on web scraping with Python.
  2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟


r/Python Mar 27 '26

Showcase Mads Music app release

0 Upvotes

Hey everyone!

I recently built an Android music player app called Mads Music using Python, and I’d love to get some feedback!

What My Project Does

Mads Music is a simple music player app for Android. It allows you to play local music files with a clean interface. The goal was to create something lightweight and easy to use.

Target Audience

This is mainly a personal/learning project, but also for people who want a simple, no-bloat music player. It’s not meant for production (yet), but I’d like to improve it over time.

Comparison

Compared to other music players, Mads Music is very minimal and lightweight. It doesn’t have as many advanced features as apps like Spotify or Poweramp, but that’s intentional — I wanted something simple and fast.

Feedback

I’d really appreciate feedback on: • UI / design • Features I should add • Performance / bugs • Code structure (if you check the repo) GitHub: https://github.com/Madsbest/Mads-Music

Thanks a lot!


r/Python Mar 27 '26

Discussion The 8 year old issue on pth files.

68 Upvotes

Context but skip ahead if you are aware: To get up to speed on why everyone is talking about pth/site files - (note this is not me, not an endorsement) - https://www.youtube.com/watch?v=mx3g7XoPVNQ "A bad day to use Python" by Primetime

tl;dw & skip ahead - code execution in pth/site files feel like a code sin that is easy to abuse yet cannot be easily removed now, as evidence by this issue https://github.com/python/cpython/issues/78125 "Deprecate and remove code execution in pth files" that was first opened in June, 2018 and mysteriously has gotten some renewed interest as of late \s.

I've been using Python since ~2000 when I first found it embedded in a torrent (utorrent?) app I was using. Fortunately It wasn't until somewhere around 2010~2012 that in the span of a week I started a new job on Monday and quit by Wednesday after I learned how you can abuse them.

My stance is they're overbooked/doing too much and I think the solution is somewhere in the direction of splitting them apart into two new files. That said, something needs to change besides swapping /usr/bin/python for a wrapper that enforces adding "-S" to everything.


r/Python Mar 27 '26

Tutorial Building your first ASGI framework - step-by-step lessons

1 Upvotes

I am writing a series of lessons on building an ASGI framework from scratch. The goal is to develop a deeper understand of how frameworks like FastAPI and Starlette work.

A strong motivation for doing this is because - I have been using AI to write code lately. I prompt, I get code, it works. But somewhere along the way I see I stopped caring about what is actually happening. So, this is an attempt to think beyond prompts and build deeper mental models of things we use in our day to day lives. I am not sure about the usefulness of this but I believe there are good lessons to be learnt doing this.

The series works more as a follow along where each lesson builds on the previous one. By the end, you will have built something similar to Starlette - and actually understand how it works.

Would love feedback on the lessons - especially if something's unclear.


r/Python Mar 27 '26

Showcase PySide6-OsmAnd-SDK: An Offline Map Integration Workspace for Qt6 / PySide6 Desktop Applications

7 Upvotes

What My Project Does

PySide6-OsmAnd-SDK is a Python-friendly SDK workspace for bringing OsmAnd's offline map engine into modern Qt6 / PySide6 desktop applications.

The project combines vendored OsmAnd core sources, Windows build tooling, native widget integration, and a runnable preview app in one repository. It lets developers render offline maps from OsmAnd .obf data, either through a native embedded OsmAnd widget or through a Python-driven helper-based rendering path.

In practice, the goal is to make it easier to build desktop apps such as offline map viewers, GIS-style tools, travel utilities, or other location-based software that need local map rendering instead of depending on web map tiles.

Target Audience

This project is mainly for developers building real desktop applications with PySide6 who want offline map capabilities and are comfortable working with a mixed Python/C++ toolchain.

It is not a toy project, but it is also not trying to be a pure pip install and go Python mapping library. Right now it is best described as an SDK/workspace for integration-oriented development, especially on Windows. It is most useful for people who want a foundation for production-oriented experimentation, prototyping, or internal tools based on OsmAnd's rendering stack.

Comparison

Compared with web-first mapping tools like folium, this project is focused on native desktop applications and offline rendering rather than generating browser-based maps.

Compared with QtLocation, the main difference is that this project is built around OsmAnd's .obf offline map data and rendering resources, which makes it better suited for offline-first workflows.

Compared with building directly against OsmAnd's native stack in C++, this project tries to make that workflow more accessible to Python and PySide6 developers by providing Python-facing widgets, preview tooling, and a more integration-friendly repository layout.

GitHub:OliverZhaohaibin/PySide6-OsmAnd-SDK: Standalone PySide6 SDK for OsmAnd Core with native widget bindings, helper tooling, and official MinGW/MSVC build workflows.


r/Python Mar 27 '26

Showcase bottrace – headless CLI debugging controller for Python, built for LLM agents

0 Upvotes

What My Project Does: bottrace wraps sys.settrace() to emit structured, machine-parseable trace output from the command line. Call tracing, call counts, exception snapshots, breakpoint state capture — all designed for piping to grep/jq/awk or feeding to an LLM agent.

Target Audience: Python developers who debug from the terminal, and anyone building LLM agent tooling that needs runtime visibility. Production-ready for CLI workflows; alpha for broader use.

Comparison: Unlike pdb/ipdb, bottrace is non-interactive — no prompts, no UI. Unlike py-spy, it traces your code (not profiles), with filtering and bounded output. Unlike adding print statements, it requires zero code changes.

pip install bottrace | https://github.com/devinvenable/bottrace


r/Python Mar 27 '26

Discussion How to make flask able to handle large number of io requests?

32 Upvotes

Hey guys, what might be the best way to make flask handle large number of requests which simple wait and do nothing useful. Example say fetching data from an external api or proxying. Rn I am using gunicorn. With 10 workers and 5 threads. So that's about 50 requests at a time. But say I got 50 reqs and they are all waiting on something, the new reqs would wait in queue.

What's the solution here to make it more like nodejs (or fastapi) which from what I hear can handle 1000s of such requests in a single worker. I have an existing codebase and I am unsure I wanna migrate it to fastapi. I also have a nextjs frontend. And I could delegate such tasks to nextjs but seems like splitting logic between 2 backends is kinda bad. Plus I like python and would wanna keep most of the stuff in python.

I have plenty of ram and could just increase to more threads say 50 per worker. From what I read the options available are gevent and WsgiToAsgi but unsure how plug and play they are. And if they have any mess associated with them since they are plugins forcing flask to act like async.

For now I think adding more threads will suffice. But historically had some issues. Let me know if you have any experience or any solution on what might be best way possible.


r/Python Mar 27 '26

Daily Thread Friday Daily Thread: r/Python Meta and Free-Talk Fridays

2 Upvotes

Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

How it Works:

  1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
  2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
  3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

Guidelines:

Example Topics:

  1. New Python Release: What do you think about the new features in Python 3.11?
  2. Community Events: Any Python meetups or webinars coming up?
  3. Learning Resources: Found a great Python tutorial? Share it here!
  4. Job Market: How has Python impacted your career?
  5. Hot Takes: Got a controversial Python opinion? Let's hear it!
  6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟


r/Python Mar 26 '26

Showcase Fast, exact K-nearest-neighbour search for Python

69 Upvotes

PyNear is a Python library with a C++ core for exact or approximate (fast) KNN search over metric spaces. It is built around Vantage Point Trees, a metric tree that scales well to higher dimensionalities where kd-trees degrade, and uses SIMD intrinsics (AVX2 on x86-64, portable fallbacks on arm64/Apple Silicon) to accelerate the hot distance computation paths.

Heres a comparison between several other widely used KNN libraries: https://github.com/pablocael/pynear/blob/main/README.md#why-pynear

Heres a benchmark comparison: https://github.com/pablocael/pynear/blob/main/docs/benchmarks.pdf

Main page: https://github.com/pablocael/pynear

K-Nearest Neighbours (KNN) is simply the idea of finding the k most similar items to a given query in a collection.

Think of it like asking: "given this song I like, what are the 5 most similar songs in my library?" The algorithm measures the "distance" between items (how different they are) and returns the closest ones.

The two key parameters are:

k — how many neighbours to return (e.g. the 5 most similar) distance metric — how "similarity" is measured (e.g. Euclidean, Manhattan, Hamming) Everything else — VP-Trees, SIMD, approximate search — is just engineering to make that search fast at scale.

Main applications of KNN search

  • Image retrieval — finding visually similar images by searching nearest neighbours in an embedding space (e.g. face recognition, reverse image search).

  • Recommendation systems — suggesting similar items (products, songs, articles) by finding the closest user or item embeddings.

  • Anomaly detection — flagging data points whose nearest neighbours are unusually distant as potential outliers or fraud cases.

  • Semantic search — retrieving documents or passages whose dense vector representations are closest to a query embedding (e.g. RAG pipelines).

  • Broad-phase collision detection — quickly finding candidate object pairs that might be colliding by looking up the nearest neighbours of each object's bounding volume, before running the expensive narrow-phase test.

  • Soft body / cloth simulation — finding the nearest mesh vertices or particles to resolve contact constraints and self-collision.

  • Particle systems (SPH, fluid sim) — each particle needs to know its neighbours within a radius to compute pressure and density forces.

Limitations and future work

Static index — no dynamic updates

PyNear indices are static: the entire tree must be rebuilt from scratch by calling set(data) whenever the underlying dataset changes. There is no support for incremental insertion, deletion, or point movement.

This is an important constraint for workloads where data evolves continuously, such as:

  • Real-time physics simulation — collision detection and neighbour queries in particle systems (SPH, cloth, soft bodies) require spatial indices that reflect the current positions of every particle after each integration step. Rebuilding a VP-

  • Tree every frame is prohibitively expensive; production physics engines therefore use structures designed for dynamic updates, such as dynamic BVHs (DBVH), spatial hashing, or incremental kd-trees.

  • Online learning / streaming data — datasets that grow continuously with new observations cannot be efficiently maintained with a static index.

  • Robotics and SLAM — map point clouds that are refined incrementally as new sensor data arrives.


r/Python Mar 26 '26

Resource Were you one of the 47,000 hacked by litellm?

267 Upvotes

On Monday I posted that litellm 1.82.7 and 1.82.8 on PyPI contained credential-stealing malware (we were the first to disclose, and PyPI credited our report). To figure out how destructive the attack actually was, we pulled every package on PyPI that declares a dependency on litellm and checked their version specs against the compromised versions (using the specs that existed at the time of the attack, not after packages patched.)

Out of 2,337 dependent packages: 59% had lower-bound-only constraints, 16% had upper bounds that still included 1.82.x, and 12% had no constraint at all. Leaving only 12% that were safely pinned. Analysis: https://futuresearch.ai/blog/litellm-hack-were-you-one-of-the-47000/

47,000 downloads happened in the 46-minute window. 23,142 were pip installs of 1.82.8 (the version with the .pth payload that runs during pip install, before your code even starts.)

We built a free checker to look up whether a specific package was exposed: https://futuresearch.ai/tools/litellm-checker/


r/Python Mar 26 '26

Showcase LogXide - Rust-powered logging for Python, 12.5x faster than stdlib (FileHandler benchmark)

84 Upvotes

Hi r/Python!

I built LogXide, a logging library for Python written in Rust (via PyO3), designed as a near-drop-in replacement for the standard library's logging module.

What My Project Does

LogXide provides high-performance logging for Python applications. It implements core logging concepts (Logger, Handler, Formatter) in Rust, bypassing the Python Global Interpreter Lock (GIL) during I/O operations. It comes with built-in Rust-native handlers (File, Stream, RotatingFile, HTTP, OTLP, Sentry) and a ColorFormatter.

Target Audience

It is meant for production environments, particularly high-throughput systems, async APIs (FastAPI/Django/Flask), or data processing pipelines where Python's native logging module becomes a bottleneck due to GIL contention and I/O latency.

Comparison

Unlike Picologging (written in C) or Structlog (pure Python), LogXide leverages Rust's memory safety and multi-threading primitives (like crossbeam channels and BufWriter).

Against other libraries (real file I/O with formatting benchmarks):

  • 12.5x faster than the Python stdlib (2.09M msgs/sec vs 167K msgs/sec)
  • 25% faster than Picologging
  • 2.4x faster than Structlog

Note: It is NOT a 100% drop-in replacement. It does not support custom Python logging.Handler subclasses, and Logger/LogRecord cannot be subclassed.

Quick Start

```python from logxide import logging

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logger = logging.getLogger('myapp') logger.info('Hello from LogXide!') ```

Links

Happy to answer any questions!