Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Tuesday Daily Thread: Advanced questions

# Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

## How it Works:

1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.

## Guidelines:

* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.

## Recommended Resources:

* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.

## Example Questions:

1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the

/r/Python
https://redd.it/1onsfns
Just got $5K AWS credits approved for my startup

Didn’t expect this to still work in 2025, but I just got **$5,000 in AWS credits** approved for my small startup.

We’re not in YC or any accelerator just a verified startup with:

* a **website**
* a **business email**
* and an actual product in progress

It took around 2–3 days to get verified, and the credits were added directly to the AWS account.

So if you’re building something and have your own domain, there’s still a valid path to get AWS credits even if you’re not part of Activate.

If anyone’s curious or wants to check if they’re eligible, DM me I can share the steps.

/r/django
https://redd.it/1onmrq5
Intercom — Open-Source WebRTC Audio & Video Intercom System in Python

Hi Friends,

I just finished an open-source project called Intercom. It turns any computer with a microphone, speakers, and webcam into a remote intercom. You can talk, listen, and watch in real time through your browser using WebRTC.

Repo: https://github.com/zemendaniel/intercom

# What My Project Does

Intercom allows a single user to remotely stream video and audio from a Linux machine to a browser. The user can monitor a space and communicate in real-time with anyone watching. It uses WebRTC for low-latency streaming and Python/Quart as the backend.

# Target Audience

Hobbyists or developers who want a self-hosted intercom system
People looking for a lightweight, Python-based WebRTC solution
Small deployments where 1 user streams and 1 viewer watches

>

# Comparison

Unlike commercial tools like Zoom or Jitsi, Intercom is:

Self-hosted: No third-party servers required for video/audio except for optional TURN relay.
Lightweight & Python-powered: Easy to read, modify, and extend.
Open-source GPLv3 licensed: Guarantees users can use, modify, and redistribute freely.

# Features

🔊 Two-way audio communication
🎥 Live video streaming
🔐 Password-protected single-user login
⚙️ Built with Python, Quart, and aiortc
🧩 Uses Coturn for TURN/STUN relay support
🖥️ Easy deployment on Linux (Ubuntu/Debian)

# Tech Stack

Python 3.11+
Quart (async web framework)
aiortc (WebRTC + media handling)
Hypercorn

/r/Python
https://redd.it/1onnwlx
In which cases you use custom middlewares

I understand what middlewares are and how they work. But in django, they are global in nature. So, in most projects with versatile requirements, especially with roles, why would anyone want to use global middlewares other than for logging.

As a developer, when have you felt the need to use custom global middlewares?

I really want to understand its use cases so I can better prepare this topic.

Thanks a lot.

/r/djangolearning
https://redd.it/1onq17b
What are some of the most interesting Django projects you worked on?

What are some of the most interesting Django projects you worked on? Be they in a professional or personal capacity. Be mindful if using a professional example not to divulge anything considered sensitive.

/r/django
https://redd.it/1onfdra
Showcase trendspyg - Python library for Google Trends data (pytrends
replacement)

What My Project Does



trendspyg retrieves real-time Google Trends data with two approaches:



RSS Feed (0.2s) - Fast trends with news articles, images, and sources

CSV Export (10s) - 480 trends with filtering (time periods, categories,

regions)



pip install trendspyg



from trendspyg import download_google_trends_rss



\# Get trends with news context in <1 second

trends = download_google_trends_rss('US')



print(f"{trends[0\]['trend'\]}: {trends[0\]['news_articles'\][0\]['headline'\]}")

\# Output: "xrp: XRP Price Faces Death Cross Pattern"



Key features:

\- 📰 News articles (3-5 per trend) with sources

\- 📸 Images with attribution

\- 🌍 114 countries + 51 US states

\- 📊 4 output formats (dict, DataFrame, JSON, CSV)

\- 188,000+ configuration options



\---

Target Audience



Production-ready for:



\- Data scientists: Multiple output formats, 24 automated tests, 92% RSS

coverage

\- Journalists: 0.2s response time for breaking news validation with credible

sources

\- SEO/Marketing: Free alternative saving $300-1,500/month vs commercial APIs

\- Researchers: Mixed-methods ready (RSS = qualitative, CSV = quantitative)



Stability: v0.2.0, tested on Python 3.8-3.12, CI/CD pipeline active



\---

Comparison



vs. pytrends (archived April 2025)





/r/Python
https://redd.it/1oo8fka
CoreSpecViewer: An open-source hyperspectral core scanning platform

# [](https://www.reddit.com/r/Python/?f=flair_name%3A%22Showcase%22)[CoreSpecViewer](https://github.com/Russjas/CoreSpecViewer/tree/main)

This is my first serious python repo, where I have actually built something rather than just "learn to code" projects.

It is pretty niche, a gui for hyperspectral core scanning workflows, but I am pretty pleased with it.

I hope that I have set it up in such a way that I can add pages with extra functionality, additional instrument manufacturers.

If anyone is nerdy enough to want to play with it free data can be downloaded from:

Happy to recieve all comments and criticisms, particularly if anyone does try it on data and breaks it!

**What my project does:**

This is a platform for opening raw hyperspectral core scanning data, processing and performing necessary corrections and processing for interpretation. It also handles all loading and saving of data, including products

**Target Audience**

Principally geologist working with drill core, this data is becoming more and more available, but there is limited choice in commercial applications and most open-souce solution require command line or scripting

**Comparison**
This is similar to many open-source python libraries, and uses them extensively, but is the only desktop based GUI platform

/r/Python
https://redd.it/1oo8lpf
How often does Python allocate?

Recently a tweet blew up that was along the lines of 'I will never forgive Rust for making me think to myself “I wonder if this is allocating” whenever I’m writing Python now' to which almost everyone jokingly responded with "it's Python, of course it's allocating"

I wanted to see how true this was, so I did some digging into the CPython source and wrote a blog post about my findings, I focused specifically on allocations of the `PyLongObject` struct which is the object that is created for every integer.

I noticed some interesting things:

1. There were a lot of allocations
2. CPython was actually reusing a lot of memory from a freelist
3. Even if it _did_ allocate, the underlying memory allocator was a pool allocator backed by an arena, meaning there were actually very few calls to the OS to reserve memory

Feel free to check out the blog post and let me know your thoughts!

/r/Python
https://redd.it/1ooe0g4
Type safe, coroutine based, purely functional algebraic effects in Python.

Hi gang. I'm a huge statically typed functional programming fan, and I have been working on a functional effect system for python for some years in multiple different projects.

With the latest release of my project https://github.com/suned/stateless, I've added direct integration with asyncio, which has been a major goal since I first started the project. Happy to take feedback and questions. Also, let me know if you want to try it out, either professionally or in your own projects!

What My Project Does

Enables type safe, functional effects in python, without monads.

Target Audience

Functional Python Enthusiasts.

/r/Python
https://redd.it/1oolq4o
Real time execution?

Hello my wonderful reddit pythonists!

I have for you a question:
Is there any existing solution that effectively achieve real-time output of every line as I type?

Some background:
I am a mechanical engineer (well a student, final year) and often do many different calculations and modelling of systems in software. I find that "calculators" often don't quite hit the level of flexibility id like to see; think Qalculate for example. Essentially, what I desire is a calculator where I can define variables, write equations, display plots, etc and be able to change a earlier variable having everything below it update in real-time.
Note: I am NOT new to python/programming. Talk dirty (technical) to me if you must.

What I have already explored:
Jupyter - Cell based, fine for some calculations where there may be a long running step (think meshing or heavy iteration). Doesn't output all results, only the last without a bunch of print() statements. Requires re-running all cells if a early variable is updated.

Marimo - Closer then Jupyter. Still cell based but updates dynamically. This is pretty close but still not there as it only seems to update dynamically with Marimo ui elements (like scroll bars)

/r/Python
https://redd.it/1oolpva
Weak Incentives (Py3.12+) — typed, stdlib‑only agent toolkit

What My Project Does
Weak Incentives is a lean, stdlib‑first runtime for side‑effect‑free background agents in Python. It composes dataclass‑backed prompt trees that render deterministic Markdown, parses strict JSON, and records plans/tool calls/staged edits in a session ledger with reducers, rollback, a sandboxed VFS, planning tools, and optional Python‑eval (via asteval). Adapters (OpenAI/LiteLLM) are optional and add structured output + tool orchestration.

Target Audience
Python developers building LLM agents or automation who want reproducibility/auditability, typed I/O, and minimal dependencies (Python 3.12+).

Comparison
Most frameworks emphasize graph schedulers/optimizers or pull in heavy deps. Weak Incentives centers deterministic prompt composition and fail‑closed structured outputs, with a built‑in session/event model (reducers, rollback) and sandboxed VFS/planning; it works provider‑free for rendering/state and adds adapters only when you evaluate.

Source Code:
https://github.com/weakincentives/weakincentives

/r/Python
https://redd.it/1oohs41
pyro-mysql v0.1.8: a fast MySQL client library

What My Project Does
pyro-mysql is a fast sync/async MySQL library backed by Rust
Repo
https://github.com/elbaro/pyro-mysql/
Bench
https://github.com/elbaro/pyro-mysql/blob/main/BENCHMARK.md
For small sync SELECT, `pyro-mysql` is 40% faster than `mysqlclient`
For small async SELECT, pyro-mysql is 30% faster than aiomysql
For large SELECT, `pyro-mysql (async)` is x3 faster than `aiomysql/asyncmy`
An experimental wtx backend (not included in v0.1.8) is x5 faster than aiomysql.
For sync INSERT, `pyro-mysql` is 50% faster than `mysqlclient`
For async INSERT, pyro-mysql is 20% slower than aiomysql
Target Audience: the library aims to be production-ready
Comparison: see the previous post

v0.1.8 adds the sqlalchemy support with the following dialects:

mysql+pyro\_mysql://
mysql+pyro_mysql_async://
mariadb+pyro\_mysql://
mariadb+pyro_mysql_async://

It is tested against related test suites from the sqlalchemy repo.

/r/Python
https://redd.it/1oo4uuk
Optimizing filtered vector queries from tens of seconds to single-digit milliseconds in PostgreSQL

We actively use pgvector in a production setting for maintaining and querying HNSW vector indexes used to power our recommendation algorithms. A couple of weeks ago, however, as we were adding many more candidates into our database, we suddenly noticed our query times increasing linearly with the number of profiles, which turned out to be a result of incorrectly structured and overly complicated SQL queries.

Turns out that I hadn't fully internalized how filtering vector queries really worked. I knew vector indexes were fundamentally different from B-trees, hash maps, GIN indexes, etc., but I had not understood that they were essentially incompatible with more standard filtering approaches in the way that they are typically executed.

I searched through google until page 10 and beyond with various different searches, but struggled to find thorough examples addressing the issues I was facing in real production scenarios that I could use to ground my expectations and guide my implementation.

Now, I wrote a blog post about some of the best practices I learned for filtering vector queries using pgvector with PostgreSQL based on all the information I could find, thoroughly tried and tested, and currently in deployed in production use. In it I try to provide:

\-

/r/Python
https://redd.it/1ooy326
What is the point of CSRF for form validation?

Hello,

I am currently in the process of building a small app aiming to localy train small AI models. I keep seeing on the internet that desactivating the CSRF in forms is super dangerous, but is it if the app will be run localy only, and not have "sensitive" (ie account management) informations uploaded?

Right now I have forms to upload a project name and training files, I don't think I need CSRF for these?

Thanks in advance

/r/flask
https://redd.it/1oo94xx
Free Introductory Python Book (amongst others)

I recently discovered the wonderful collection of free textbooks made available by the openstax organisation (https://openstax.org/). There are many books available covering a wide range of disciplines but there’s one in particular that may be of interest to redditors here, namely Introduction to Python Programming: https://openstax.org/details/books/introduction-python-programming

Another notable example is Principles of Data Science: https://openstax.org/details/books/principles-data-science

There are many others including texts on mathematics and computer science.

/r/Python
https://redd.it/1op1ghd
First event Django Day India is here - November 8, 2025

We’re excited to invite you to Django Day India 2025, the biggest Django community event in the country!

The schedule is now live, featuring talks on Django, Python, architecture, scalability, and open source from some of the most active contributors in the ecosystem.

Keynote Speakers:

Thibaud Colas — President, Django Software Foundation & Tech Lead at Torchbox

Sarah Abderemane — Vice President, Django Software Foundation & Software Engineer at Kraken Tech

Whether you’re building with Django daily or just passionate about web development, this is a great chance to learn, connect, and be part of India’s growing Django community

Tickets are closing tomorrow , so grab yours before they sell out!

tickets: https://konfhub.com/djangoday-india-2025

Official website: djangoday.in

Come for the code, stay for the community!

/r/django
https://redd.it/1op14p2
Looking for a Mentor

Hello Everyone,

I started learning Django today, I need a mentor, who can guide me in this Journey.

TIA.

/r/djangolearning
https://redd.it/1ooqqdb
Can anyone suggest me resources to learn django, need to make an ai chat ap with semantic search on chats



/r/djangolearning
https://redd.it/1oms8o8