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/1k4sm06
Make your module faster in benchmarks by using tariffs on competing modules!

Make your Python module faster! Add tariffs to delay imports based on author origin. Peak optimization!
https://github.com/hxu296/tariff

/r/Python
https://redd.it/1k4qhdd
Thread or process vs celery

I have a service a client connect with web socket. When the service get a connection, it will trigger a task that should run as long as the web socket connection is alive. The task is like doing something regularly every second, then update the client through the web socket so that the client can view it on the display.

How do I architect this? At first I thought I should use channel and celery to do the task but then it's not really like a traditional task a celery worker is supposed to do but it's rather very long running task almost like another service (running like 1 hr or as long as websocket is alive, and it should update the client in real time very second). Is it better to fork process/thread and run it on demand? If I use thread, how do I manage work thread and scale it out and down?

Is Django not appropriate here? I'll have the web page run with Django anyway.

/r/django
https://redd.it/1k4zc5u
6th Datathon - a Virtual Data Science Hackathon is happening this weekend

DubsTech UW is hosting a virtual Datathon this Saturday, April 26 and Sunday, April 27. Do join us if you love data analytics, data visualization, or machine learning and want to put your skills to the test. Our data science hackathon is 100% beginner friendly and you can use Python or any other tool to build your projects!

Get an opportunity to work on real world datasets and get feedback from our panel of 11 judges. So come build with friends, make new friends, learn new skills and compete with data lovers from around the world.

Register Here: https://datathon2025.webflow.io/

Date: April 26 & 27, 2025
Location: Zoom (Virtual)

/r/Python
https://redd.it/1k4b7lx
django-simple-captcha ? My form was a spam magnet

My contact form was getting so much spam I couldn't find real inquiries anymore.

I implemented django-simple-captcha and the spam completely disappeared. I customized it to match my dark theme (you can see it at https://www.eriktaveras.com/contact/) and it works perfectly.

But I'm wondering if it's the best long-term option.

What do you use? django-simple-captcha, Google reCAPTCHA, honeypot fields, or something else?

Have you noticed any impact on conversion rates with different options?

/r/django
https://redd.it/1k4ldy3
Need help with IIS please

Hi everyone,
I'm trying to deploy my Django web app to Window 2019 IIS server.
I follow this instruction:
https://www.youtube.com/watch?v=APCQ15YqqQ0&t=1123s
Function work, how ever, the static template file seem not work properly.
What's the properly problem?.
I try to install window server on my computer and follow instruction and it work.
Please advise .
Thank you

/r/django
https://redd.it/1k51vv9
Need Help in Creating a Full Stack This is my First tym Doing a Project

I'm Doing A Project on Multi Asset Portfolio management which takes and This is my First tym Doing a Full Stack Project and i Dont know How to Do it and there i Am Getting many Errors which i am Getting in Fetching Data and other Parts. Please help me in Completion of this Project and now i am trying to Integrate a Project with mine na i am getting erors wheni am Trying to run it

/r/flask
https://redd.it/1k4zpor
HELP

/r/djangolearning
https://redd.it/1k4zybv
1,000 Python exercises

Hi r/Python!

I recently compiled 1,000 Python exercises to practice everything from the basics to OOP in a level-based format so you can practice with hundreds of levels and review key programming concepts.

A few months ago, I was looking for an app that would allow you to do this, and since I couldn't find anything that was free and/or ad-free in this format, I decided to create it for Android users.

I thought it might be handy to have it in an android app so I could practice anywhere, like on the bus on the way to university or during short breaks throughout the day.

I'm leaving the app link here in case you find it useful as a resource:
https://play.google.com/store/apps/details?id=com.initzer\_dev.Koder\_Python\_Exercises

/r/Python
https://redd.it/1k56mio
R One Embedding to Rule Them All

Pinterest researchers challenge the limits of traditional two-tower architectures with OmniSearchSage, a unified query embedding trained to retrieve pins, products, and related queries using multi-task learning. Rather than building separate models or relying solely on sparse metadata, the system blends GenAI-generated captions, user-curated board signals, and behavioral engagement to enrich item understanding at scale. Crucially, it integrates directly with existing systems like PinSage, showing that you don’t need to trade engineering pragmatism for model ambition. The result - significant real-world improvements in search, ads, and latency, and a compelling rethink of how large-scale retrieval systems should be built.


Full paper write-up here: https://www.shaped.ai/blog/one-embedding-to-rule-them-all

/r/MachineLearning
https://redd.it/1k5b3ni
Django - OAuth2 Settings with Google Login >> Experiencing Delusion

Hi everyone, me again 🧉 This time I have some doubts about OAuth2 and Django.
My goal is to set up authentication for my web app ONLY through Google — meaning users should be able to log in or register using their Google accounts.

After some research, I came across the dj-rest-auth package. I’d like to implement it together with djangorestframework-simplejwt, but that's where things start getting a bit dizzy for me.
I'm wondering if any of you have gone through this kind of setup before. If so, any tips, advice, or references would be hugely appreciated!

/r/djangolearning
https://redd.it/1k5etw5
[Resolved]SQLite "unable to open database file" with relative path in Flask project

In my Flask project (running on a Mac virtual environment), I encountered an error when using a relative path for a SQLite database.

I placed `test.db` in a subfolder `temp/` under the project root, like this:

/flask_root/temp/test.db

And in my `__init__.py` file (located under a different subfolder), I configured the database URI like this:

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///temp/test.db'

However, I got the following error:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/20/e3q8)

After some trial and error, I discovered that using an **absolute path** worked:
import os

base_dir = os.path.abspath(os.path.dirname(__file__))
db_path = os.path.join(os.path.dirname(base_dir), 'temp', 'test.db')
app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{db_path}'

**My findings here:**

The issue comes from how **SQLite handles relative paths** differently than Python does:

* **SQLite resolves paths relative to its own execution context**.
* **Python (e.g.,** `os.path.exists(), __init__.py`\*\*) resolves paths based on the interpreter's context\*\*.

If you're using Flask's **application factory pattern**, the app might initialize from a different directory than where you run it. This can make relative paths unreliable unless you ensure all code executes from the exact same working directory—which is tricky to control.

Using absolute paths is a more

/r/flask
https://redd.it/1k4yxv8
faceit-python: Strongly Typed Python Client for the FACEIT API

What My Project Does

faceit-python is a high-level, fully type-safe Python wrapper for the FACEIT REST API. It supports both synchronous and asynchronous clients, strict type checking (mypy-friendly), Pydantic-based models, and handy utilities for pagination and data access.

Target Audience

Developers who need deep integration with the FACEIT API for analytics, bots, automation, or production services.
The project is under active development, so while it’s usable for many tasks, caution is advised before using it in production.

Comparison

Strict typing: Full support for type hints and mypy.
Sync & async interfaces: Choose whichever style fits your project.
Modern models: All data is modeled with Pydantic for easy validation and autocompletion.
Convenient pagination: Methods like .map(), .filter(), and .find() are available on paginated results.

Compared to existing libraries, faceit-python focuses on modern Python, strict typing, and high code quality.

Feedback, questions, and contributions are very welcome! GitHub: https://github.com/zombyacoff/faceit-python

/r/Python
https://redd.it/1k5idmt
DjangoCon Europe 2025

If you are attending DjangoCon Europe this week here are my tips to make the most of your experience whether it's your first time or you are a DjangoCon regular!

📆 Plan your talk viewing schedule
Attend the Lightning Talks
🔄 Network during the breaks
🪩 Attend the social events - this includes the Django.Social after day one in the City Centre (All welcome - details on the discord https://discord.gg/BJyHR63P)
🏃‍♀️‍➡️ Get involved in the sprints
💻 Join in on Slack
🔥Don’t burn out

I have expanded on each point here: https://foxleytalent.com/blog/djangocon-europe-2025/

See you in Dublin🍀

/r/django
https://redd.it/1k5hcdl
Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1k5lh9f
Backend failing to start - Electron react js front end and flask backend

I am developing a desktop app for cross platform users. I packaged backend flask using pyinstaller as a standalone executable file and then built the electron as single executable file for all three platforms using GitHub actions workflow. I am able to run the workflow and download artefacts but when I install the app in my windows I see that the backend is not starting at all. I am new to full stack development and would like to know the possible issues for this to happen. Or is there any way I could package this app but running flask in the local machine is out of scope.

/r/flask
https://redd.it/1k5ix19
CPython's optimization for doubly linked lists in deque (amortizes 200% link memory overhead)

I was reading through CPython's implementation for `deque` and noticed a simple but generally useful optimization to amortize memory overhead of node pointers and increase cache locality of elements by using fixed length blocks of elements per node, so sharing here.

I'll apply this next when I have the pleasure of writing a doubly linked list.

From: [Modules/\_collectionsmodule.c#L88-L94](https://github.com/python/cpython/blob/b5bf8c80a921679b23548453565f6fd1f79901f2/Modules/_collectionsmodule.c#L88-L94)

* Textbook implementations of doubly-linked lists store one datum
* per link, but that gives them a 200% memory overhead (a prev and
* next link for each datum) and it costs one malloc() call per data
* element. By using fixed-length blocks, the link to data ratio is
* significantly improved and there are proportionally fewer calls
* to malloc() and free(). The data blocks of consecutive pointers
* also improve cache locality.

/r/Python
https://redd.it/1k5nxvt
Where to deploy a simple portfolio project?

Hi guys, as a question states. It was my 3rd approach to railway and I'm giving up a little. Is there any plug and play Django dedicated hosting service? Cheap or free would be preferred.

/r/djangolearning
https://redd.it/1k5h9pk
lsoph - a TUI for viewing file access by a process

# 📁 `lsoph`

TUI that lists open files for a given process. Uses `strace` by default, but also `psutil` and `lsof` so will sort-of-work on Mac and Windows too.

Usage:

```shell
uvx pip install lsoph
lsoph -p <pid>
```

# [🎬 Demo Video](https://asciinema.org/a/c7T8id39jU7ap6E0D99S5dJ6F)

Project links:

* [🏠 home](https://bitplane.net/dev/python/lsoph)
* [🐱 github](https://github.com/bitplane/lsoph)
* [🐍 pypi](https://pypi.org/project/lsoph)


## Why?

Because I often use `strace` or `lsof` with `grep` to figure out what a program is doing, what files it's opening etc. It's easier than looking for config files. But it gets old fast, what I really want is a list of files for a tree of processes, with the last touched one at the top, so I can see what it's trying to do. And I wan to filter out ones I don't care about. And I want this in a tmux panel too.

So, I'd heard good things about Gemini 2.5 Pro, and figured it'd only take a couple of hours. So I decided to create it as GenAI slop experiment.

This descended into madness over the course of a weekend, with input from ChatGPT and Claude to keep things moving.

**I do not recommend this. Pure AI driven coding is not ready for prime-time**.

Vibe coders, I never realised how bad you have it!

## retro

Here's some notes on

/r/Python
https://redd.it/1k5kj23