r/Python • u/masher_oz • May 05 '26
News PySimpleGUI 6 is LGPL again
Looks like the commercialisation of PySimpleGUI has come to an end.
PySimpleGUI 6 - Back to LGPL3 https://github.com/PySimpleGUI/PySimpleGUI
r/Python • u/masher_oz • May 05 '26
Looks like the commercialisation of PySimpleGUI has come to an end.
PySimpleGUI 6 - Back to LGPL3 https://github.com/PySimpleGUI/PySimpleGUI
r/Python • u/AutoModerator • May 05 '26
Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.
Let's deepen our Python knowledge together. Happy coding! š
r/Python • u/Loren-PSF • May 04 '26
Me* ā I hope to see a good number of you all in Long Beach, too!
If you're curious what PyCon US is about, you can take a look at the schedule, the list of events, and the list of companies that will be in the Expo Hall. But really the formal program is only like half of the experience. It's a gathering of 2K+ people who are all there for the love of Python, and just want to spend a weekend+ talking about it and learning about it and also just hanging out shooting the shbreeze or playing board games or whatever with a like-minded group of people. The best description of it I've heard is "like a family reunion you actually want to go to."
FWIW I'm v happy to answer questions if you've got 'em; it is the time of year when I am living and breathing PyCon US so the odds are very good I know the answer to whatever it is you are wondering about:)
*well, I have to because it is my job š I work for the Python Software Foundation, the non-profit behind Python and also PyCon US. But there are many other good reasons to go:)
r/Python • u/Gold-Channel8303 • May 04 '26
If youāre in the Python/data ecosystem, PyData London is about a month away- June 5-7, 2026!
Itās very Python-centric ā lots of content around libraries, workflows, and the broader PyData stack, along with real-world use cases.
Keynotes this year:
Also new this year: a keynote during Friday tutorials, so itās worth showing up from the start.
If youāve been before, you know itās a great community event. If not, itās a very approachable conference with significant practical value.
Good time to grab a ticket and start planning if youāre interested.
https://pydata.org/london2026
https://pretalx.com/pydata-london-2026/schedule/
https://ti.to/pydata/pydatalondon26
r/Python • u/AutoModerator • May 04 '26
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
r/Python • u/ResponseSeveral6678 • May 04 '26
I am super curious what naming rules do you use in Python?
Do you standardize things like:
- suffixes / prefixes (DTO, Service, Manager, etc.)
- naming length (short vs explicit)
- abstraction levels in names
Or does it change per project?
For me, naming is everything.
If I see the name - I should know precisely what it does without guesses.
I often rename the same thing 5ā10 times until it āsitsā and feels stable.
Sometimes the name becomes painfully long, but you know exactly what it does:
I just grepped the longest name in codebase
class AssertRepeatedRequestNonBytePayloadMatches: ...At what point do you stop adding meaning and accept ambiguity?
r/Python • u/Gajdi • May 04 '26
from https://krisztiangajdar.com/blog/coalescing-async-requests/
Embedding models are several times faster on a batch of 32 inputs than on 32 sequential calls of size 1. The GPU loads the weights once, runs one forward pass, returns. Sequential calls pay the kernel-launch and memory-transfer overhead 32 times.
This is well-known on the training side and annoyingly under-served on the serving side, because the natural API for callers is "embed this one thing." If you make them batch manually, half of them will not, and your throughput collapses.
The fix is a small async primitive. Callers `await evaluator.evaluate(item)` as if it were a one-at-a-time call. Inside, the primitive holds requests for a few milliseconds, accumulates whatever arrives, and dispatches them as a single batch. Each caller's future resolves to its own slice of the result.
## The interface
```python
class DelayedEvaluator[InputT, OutputT]:
def __init__(
self,
process_batch: Callable[[list[InputT]], Awaitable[list[OutputT]]],
delay_ms: int = 5,
):
self._process_batch = process_batch
self._delay_ms = delay_ms
self._lock = asyncio.Lock()
self._pending: list[_Pending[InputT, OutputT]] = []
self._task: asyncio.Task | None = None
async def evaluate(self, items: list[InputT]) -> list[OutputT]:
future = asyncio.get_running_loop().create_future()
async with self._lock:
self._pending.append(_Pending(items, future))
if self._task is None:
self._task = asyncio.create_task(self._dispatch_after_delay())
return await future
```
`_Pending` is a tiny dataclass holding the per-call inputs and the future that resolves to that call's outputs. The lock is there so two callers arriving in the same event loop tick can both register before the first dispatch fires.
## The dispatch
```python
async def _dispatch_after_delay(self):
await asyncio.sleep(self._delay_ms / 1000)
async with self._lock:
pending, self._pending = self._pending, []
self._task = None
all_inputs = [item for p in pending for item in p.items]
try:
all_outputs = await self._process_batch(all_inputs)
except Exception as exc:
for p in pending:
p.future.set_exception(exc)
return
# split results back per caller, in order.
i = 0
for p in pending:
n = len(p.items)
p.future.set_result(all_outputs[i : i + n])
i += n
```
A few things matter here.
The inputs are concatenated and the outputs are split back by length. No sorting, no IDs. `itertools.accumulate` of `len(p.items)` gives you the slice boundaries in O(n).
Exceptions fan out. A failed batch fails every caller with the same exception. Do not swallow it on some callers and not others.
The task is `None` again at the end, so that the next caller starts a fresh sleep. If you forget this, you will dispatch one batch and then permanently hang, ask me how I know.
## Choosing the delay
5ms is a reasonable default for a model that takes 50ms or more to evaluate. A 10% latency tax for 5-10x more throughput is a good trade. For very fast models (under 10ms) the delay should be smaller, or the coalescer is just the wrong tool.
The cost shows up most under low load. A single caller still waits 5ms for nothing. If your service has lulls, that latency is visible. For services that are always busy the delay is paid only by the first request in each window and amortised across the rest.
There are libraries that do this kind of thing. They are also wrappers around HTTP servers, or tied to a specific ML framework, or they expect inputs of a fixed shape. The primitive itself is around 100 lines and fits into any async codebase. Inference, database access, external API rate-limiting, anything where a batched call is faster than N individual ones.
Once it is in your toolbox you stop writing batching logic at the call sites. The caller writes `await x.evaluate(item)`, and the speedup is invisible.
r/Python • u/AutoModerator • May 04 '26
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.
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
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
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/Acceptable_Crab164 • May 03 '26
Iām looking to compile a list of Python resources that are specifically useful for those of us working in South Africa.
Aside from the standard libraries, what are you using for:
Local payment integration?
Calculating VAT/Tax?
SMS gateways?
Load-shedding schedules (API)?
Drop your recommendations below and let's build a Wiki!
r/Python • u/AutoModerator • May 03 '26
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!
Let's build and grow together! Share your journey and learn from others. Happy coding! š
r/Python • u/AutoModerator • May 02 '26
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!
Share the knowledge, enrich the community. Happy learning! š
r/Python • u/MeanMasterpiece5438 • May 01 '26
Hey, Iām building a project where users upload PDFs and I need to extract text from them.
For normal text PDFs, extraction works fine. But for scanned/image-based PDFs, Iām using Tesseract + some preprocessing.
The problem is:
Iāve also looked into Google Vision OCR, but:
Right now Iām considering:
My goal:
Questions:
Would appreciate real-world advice instead of just docs.
Thanks.
r/Python • u/amirathi • May 01 '26
Last year, I had a poor experience of using Claude Code with Jupyter Notebooks.
Recently gave it another shot using the open source Jupyter MCP Server. Setup was a bit annoying, but once it was up, it worked well.
The big difference is kernel access. Claude can now talk directly to my live IPython kernel and edit notebook cells properly (without messing the .ipynb JSON).
I just let it write notebooks, run top to bottom, debug & fix errors & only ping me when everything is working.
Any other notebook + Claude setups that work better? Has anybody tried JupyterLab AI extensions (jupyter-ai, notebook-intelligenceĀ etc.)?
r/Python • • May 01 '26
Was working on preprocessing 50k+ records and hit a massive bottleneck: using loops and .apply() in Pandas. Itās fine for toy datasets, but once you scale, it slows down experimentation and validation cycles to a crawl.
Switching to strict vectorized operations (NumPy / scikit-learn) fixed it. The strategy:
Result: ~35% faster preprocessing execution and much tighter iteration cycles.
Curious what others are doing before jumping to heavy distributed tools like Dask or Spark:
r/Python • u/jimmytoan • May 01 '26
Two versions of `lightning` (2.6.2 and 2.6.3) were published to PyPI yesterday and yanked same day after Semgrep detected them. Beyond the usual credential-stealing pattern, there's a persistence mechanism worth knowing about if you use Claude Code.
The malware writes a `SessionStart` hook to `.claude/settings.json` with `matcher: "*"`. That hook points to a Bun runtime bootstrapper for a 14.8 MB payload. Every time any developer on the machine opens Claude Code - not just in the infected project, but in any project - the hook fires automatically. A parallel hook targets VS Code via `.vscode/tasks.json` with `runOn: folderOpen`.
The exfiltration is four-channel: HTTPS POST to a C2, GitHub commits with `EveryBoiWeBuildIsAWormyBoi` as the message prefix (searchable on GitHub commit search if you want to check if you're affected), pushing to the victim's own repositories, and a GitHub Actions workflow that dumps all repository secrets via `${{ toJSON(secrets) }}`.
If it finds npm publish credentials, it worms into npm by injecting the dropper into every package that token can publish, bumps the patch version, and republishes.
Semgrep's writeup calls this "among the first documented instances of malware abusing Claude Code's hook system in a real-world attack."
If you've installed anything from PyPI recently on a machine where you use Claude Code, it's worth checking `.claude/settings.json` for unexpected `hooks.SessionStart` entries. 2.6.1 is clean.
r/Python • u/aminoy77 • May 01 '26
Building a CLI agent that falls back automatically between OpenRouter, Ollama, OpenAI, Anthropic and Gemini when one hits rate limits or goes down. Ended up building a ProviderPool class that tracks exhausted providers with timestamps and retries after a configurable window. Works well but feels like something that should already exist as a library. Searched PyPI and couldn't find anything purpose-built for this. Most LLM libraries handle single-provider retries but not cross-provider fallback. Curious if others have solved this differently or know of something I missed.
r/Python • u/AutoModerator • May 01 '26
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!
Let's keep the conversation going. Happy discussing! š
r/Python • u/Beneficial_String411 • Apr 30 '26
Working on a tool that's grown to ~4000 LOC in one .py file. argparse + 18 subcommands, stdlib + pyyaml only. Tests are in a separate dir.
Single-file has been great for:
- Debugging (one file to grep)
- Distribution (one wheel, no package layout decisions)
- Onboarding contributors
But I'm starting to wonder if it's worth keeping monolithic at this size. What's your threshold for splitting? Is it LOC, or coupling, or "I can't navigate it anymore"?
r/Python • u/Albiino_sv • Apr 30 '26
Has anyone used Marimo together with Scanpy or SpatialData?
Iāve been experimenting with Marimo and like its reactive, immutable execution model, but Iām running into friction when working with Scanpy/SpatialData objects. Many typical workflows rely on in-place mutations which doesnāt seem to fit naturally with Marimoās approach.For example, operations that modify .obs, .var, or layers in place break change tracking and reactivity.
Has anyone found a good pattern for using these tools together? Do you adapt your workflow (e.g., avoid in-place ops, copy more aggressively, or consolidate transformations into a single cell), or does it end up being more trouble than itās worth?
Curious to hear real experiences or best practices.
r/Python • u/Separate-Summer-6027 • Apr 30 '26
We wrote a tutorial on performing mesh boolean operations (union, intersection, difference) in Python using trueform. One pip install, NumPy arrays in and out.
, , =
The tutorial covers loading meshes, transformations, precomputed structures for repeated booleans on moving geometry, and intersection curve extraction.
Tutorial: https://polydera.com/tutorials/fast-mesh-booleans-in-python
If you'd like to play with it in the browser: https://trueform.polydera.com/live-examples/boolean
Examples and Source: https://github.com/polydera/trueform
r/Python • u/Fancy-Track1431 • Apr 30 '26
Iāve been applying to speak at tech conferences for ~2 years now and havenāt been selected yet.
Iām trying to understand how this works in practice, because from the outside it feels like:
- a lot of accepted speakers are developer advocates or frequent speakers.
- many talks are either very polished or on niche/deep topics.
- and increasingly, trending areas like AI seem to dominate.
Which makes me wonder where does that leave beginners or regular engineers?
Do you need to:
- already be an āexpertā in something niche?
- or be really good at packaging and presenting ideas?
Or is the CFP process unintentionally favoring people who already have speaking experience?
Iām not saying beginners should get talks just for being beginners, but it sometimes feels like thereās a gap between āI have something useful to shareā and āthis is conference-worthy.ā
Another thing I struggle with is that thereās usually no feedback on rejected CFPs, so itās hard to know what to improve.
Would really appreciate perspectives from:
What actually makes a proposal stand out? And how should someone improve without feedback?
Also, at what point does it make more sense to just share your knowledge through blogs/YouTube instead of chasing conference talks?
r/Python • u/chinmay_3107 • Apr 30 '26
Iām thinking about building a pytest / pytest-bdd plugin that helps teams define their own custom DSLs for BDD tables.
The idea is not to force one specific syntax. Instead, the package would provide the plumbing:
For example, one team might use something like:
Given the following content exists:
| Content IDs | 1..4 | 5 |
| Content* | 4:Article | Poll |
| Category* | random | News |But another team could define completely different syntax, like:
Given the following users exist:
| Users | admin x2 | editor |
| Role | Admin | Editor |The plugin would not know what āArticleā, āPollā, ārandomā, orĀ 1..4Ā means. The local project would define that.
Iām trying to understand:
Curious to hear from people using pytest-bdd or BDD-style tests in real projects.
r/Python • u/AutoModerator • Apr 30 '26
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.
Let's help each other grow in our careers and education. Happy discussing! š
The article explains concurrency in Python including topics like multithreading, multiprocessing, race conditions, and synchronization mechanisms such as locks. It then takes a deep dive into switching off GIL to enableĀ *real*Ā multithreading in Python, highlighting the differences, the benefits and the gotchas with clear code examples.
https://blog.geekuni.com/2026/04/python-concurrency.html?m=1