r/Python • u/Practical_Plan007 • Jun 02 '26
Tutorial Another Asyncio Tutorial
I converted my personal notes into a tutorial. Maybe useful for others.
Please also feel free to provide feedback. Would love to discover my blind spots.
r/Python • u/Practical_Plan007 • Jun 02 '26
I converted my personal notes into a tutorial. Maybe useful for others.
Please also feel free to provide feedback. Would love to discover my blind spots.
r/Python • u/mordechaihadad • Jun 02 '26
Usually when you run high-concurrency rate limiting inside FastAPI, you are usually forcing python's single threaded event loop to spend precious time on network driver I/O just to verify a token before the request even hits the application logic.
I wanted to see how cleanly I could isolate the Redis network layer outside of python, so I built rustgate using PyO3 and a multi-threaded tokio driver.
Disclaimer: This is basically a proof of concept. It's basically tied to another experimental crate I am working on (axum-rate-limiter), and so it's not super configurable or abstracted as of now. Could you use in production? Probably, but why?
That being said, the raw performance under a 100-concurrency flood on a heavy, dynamically rerouted endpoint turned out pretty efficient:
Pushed 1,128 req/sec without dropping a connection.
Fastest response hit 15.3 ms.
Fails closed instantly with immediate 429 rejections to protect downstream application logic.
The cool part: I benched a naked, no-op /health endpoint (literally just returning {"status": "ok"}) on the same machine, and it maxed out at 1,496 req/sec.
The fact that crossing FFI boundaries, handling memory pinning, and doing a multi-threaded Tokio to Redis round-trip only costs ~370 req/s, proves that the Rust integration added almost non existent overhead.
Iβve dropped the GitHub link in the comments section below to keep this thread focused on the performance discussion.
EDIT: Regarding the benchmarks criticism, I hear you loud and clear, and I will try to update this tomorrow, run it on linux, using `uvloop`, using 8k connections, and will add a proper baseline.
r/Python • u/ccw34uk • Jun 02 '26
In Pandas, an IntervalArray is created by:
> pd.arrays.IntervalArray([pd.Interval(0, 1), pd.Interval(1, 5)]) <IntervalArray> [(0, 1], (1, 5]] Length: 2, dtype: interval[int64, right]
Note the `[(0, 1], (1, 5]]`: what's the rationale for the opening bracket being a parenthesis but the closing bracket being square?
r/Python • u/petekindahot • Jun 02 '26
I'm a college student, I've just learned pandas and I was planning to start freelancing with openpyxl, pandas and numpy. Wanted to try gigs like data cleaning or automation services. But as I searched about openpyxl, I read that it's used to work with 2010 excel sheets. And that's all.
So my question was is this module/library still relevant?
r/Python • u/AutoModerator • Jun 02 '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/AlSweigart • Jun 01 '26
Pay at least $36 for 15 ebooks from No Starch Press benefiting the PSF: https://www.humblebundle.com/books/python-good-stuff-no-starch-books
Hello, I'm Al Sweigart, author of a few books in the bundle. Here's some info about them:
print() call that caused it. It makes coding less abstract.(Note that my books are released under a Creative Commons license and can be found online, but these ebooks have much nicer formatting than the HTML pages on my website.)
No Starch Press is my publisher, but I genuinely do love their books. The ones in this bundle that are on my to-read list that I'm especially excited about:
But of course, Python Crash Course by Eric Matthes is a great book for beginners who want to learn to code. (It consistently beats Automate the Boring Stuff on Amazon.) This is a great collection of ebooks.
Remember to max out the amount of your payment goes to the Python Software Foundation. Scroll down to and click Adjust Donation, then click Custom Amount to edit what percentage of your contribution is split between Developers/Publishers, Humble Bundle, and Charity.
r/Python • u/Cold-Detective1356 • Jun 01 '26
Looking for an interesting physics(theoretical or not) or chemistry project to work with in python.
Please include your ideas and reasons below.
Also I might send progress through, so please send suggestions for additions!
:D
r/Python • u/AutoModerator • Jun 01 '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/AutoModerator • May 31 '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/catafest • May 30 '26
MiniMax M2.7 works well on Python with the OpenAI Python package. See my test on my blog: https://python-catalin.blogspot.com/2026/05/python-31011-minimax-m27-tested-with.html
r/Python • u/sc0v0ne • May 30 '26
I can't share the code because it was a company-wide error.
The problem was that while running a Docker container within the Google Cloud platform using their tool called Google Vertex Jobs, I encountered the following error: "Free: Invalid Pointer". Inside this container, a Python script runs containing the model training I do using TensorFlow, and I also connect to the database using SQLAlchemy. However, I encountered this error where the script stopped executing the rest of the code.
Okay, up to this point it's confusing because it didn't generate a Python exception. I analyzed the executions, even within the SQLAlchemy functions, and when I removed the code, the script worked normally without this problem.
The alternative I found was to add the SQLAlchemy executions to a parallel process, separate from the model training execution structure. This allowed me to run the script without problems. Has anyone else experienced this issue? Or can you recommend an alternative?
r/Python • u/AutoModerator • May 30 '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/Aggravating-Mobile33
•
May 29 '26
This is my reply to the vulnerability CVE-2026-48710:
https://marcelotryle.com/blog/2026/05/28/cve-2026-48710-a-maintainers-perspective
r/Python • u/pplonski • May 29 '26
Hi there!
I've seen many AI data analyst projects - basically you have a chat, which has access to your data and documents and you can ask it any questions. Then it is using code and tools to provide repsponses. I create such AI data analyst and I have used ipynb notebooks format to store the conversation. I think it is perfect format for this. I can keep text, code and outputs in the single file. What is more, it is easy to publish as static web page.
What do you think about such use case for famous ipynb format? What else are you using to store conversations with AI?
r/Python • u/UnhappyPay2752 • May 29 '26
Started auditing how our data team works and the security picture was worse than expected. Notebooks querying production databases directly, credentials hardcoded in cells because environment variable setup felt like friction, code that's been copied between notebooks so many times the original author is impossible to trace.
None of it goes through any review process that the engineering team's code goes through. No SAST, no security-minded PR review, no scanning of any kind. The assumption seems to be that notebooks are exploratory and therefore informal, but at some point exploratory code started running against production data with production access and that distinction stopped meaning anything.
These notebooks often have broader data access than the application code because the people writing them needed to move fast and used their own credentials. That access never got revisited.
r/Python • u/fxboshop • May 29 '26
I am developing a Windows-based software in Python and currently using PyArmor to protect it. However, Windows Security and some antivirus programs are detecting it as a virus because of the PyArmor protection/obfuscation.
What is the best way to protect my software from cracking, reverse engineering, or piracy without triggering antivirus false positives?
r/Python • u/Beginning-Fruit-1397 • May 29 '26
says you are the maintainer of a small (50-100 stars) library.
You see someone fork your repo, mention one of your issues in his commits, so your are happy, someone taking true interest in your work!
You take a look at his branch, and there you see pure AI slop, with files at the repo root (not in the src), tests with print statement even tough you use pytest and it's clearly explained in the contributing doc, and purely hallucinated imports like "from my lib import Foo, Bar" even tough there's never any mention of these two in the code or the documentation (and thus completely incomprehensible code with subclasses from these hallucinated types, etc...)
how to best deal with this without appearing hostile to other potential future contributors?
I want contributors, I'm very happy for anyone taking a look at my work, but at the same time that person has other forks of repos where it just seems to be hunting for "good first issues" label, and thus I'm not sure on the value of giving an honest review if it's not clear on wether there's a genuine intention to resolve the issue or just collect cool github points.
EDIT 11h later:
Thanks to everyone who gave his perspective!!
I don't think I have the time immediately to answer to everyone but there's a lot of good advice here.
By the way LMAO I should have linked my lib to maybe get actual contributors, this post is doing views.
Hint: it's the top one ranked in this comparison ->
https://www.reddit.com/r/Python/comments/1rj3ct7/a_comparison_of_rustlike_fluent_iterator_libraries/
r/Python • u/AutoModerator • May 29 '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/AutoModerator • May 28 '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! π
r/Python • u/Shawn-Yang25 • May 27 '26
Hi everyone,
Apache Fory 1.0 has been released recently.
Fory is a fast multi-language serialization framework for native objects, Schema IDL, and cross-language data exchange. It supports Java, Python, C++, Go, Rust, JavaScript/TypeScript, C#, Swift, Dart, Scala, and Kotlin.
The main idea is simple: in many systems, data is not just a flat schema message. Applications often need to serialize idiomatic domain objects, nested containers, polymorphic types, object references, shared references, or even circular object graphs. Fory is designed to handle these cases efficiently while still supporting cross-language data exchange when needed.
With 1.0, Fory has reached a more stable point:
Fory is not meant to replace Protobuf everywhere. Fory is more focused on cases where you want high-performance serialization while preserving more of the native object model, or where the same data model needs to move across multiple runtimes without too much glue code.
Links:
I would be interested in feedback from people who have worked with Protobuf, FlatBuffers, Kryo, JDK serialization, pickle/cloudpickle, Avro, MessagePack, or Arrow-based systems.
What serialization problems are still painful in your multi-language systems?
r/Python • u/Dry_Raspberry4514 • May 27 '26
The vulnerability is present in Starlette, an open source framework that its developer says receives 325 million downloads per week.
r/Python • u/AutoModerator • May 26 '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/AutoModerator • May 25 '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/Consistent_Tutor_597 • May 24 '26
Hey guys. I used to work a lot with jupyter. But had to move on because .ipynb doesn't go very well in git and ai agents don't really work with them well for similar reasons.
Main culprit is not the notebook itself but .ipynb format. I understand that the notebook world evolved in inline outputs etc. But I think would be cool if .py based notebooks with #%% becomes first class citizen everywhere. There's a tool I used called jupytext which does that but it's bolted on and not native support.
The other tool I have heard about is marimo? I have never used it but it seems like it forces u to not redefine the same variable again. Which is unnatural in python. If python allows u to update a variable, ur notebook should too. But let me know what you guys think. And if there's potential for the data science world to move there anytime soon. I think most people have to explore in notebooks and then convert to py.