R LIMO: Less is More for Reasoning
>We present a fundamental discovery that challenges our understanding of how complex reasoning emerges in large language models. While conventional wisdom suggests that sophisticated reasoning tasks demand extensive training data (often >100,000 examples), we demonstrate a striking phenomenon: complex mathematical reasoning abilities can be effectively elicited with surprisingly few examples. This finding challenges not only the assumption of massive data requirements but also the common belief that supervised fine-tuning primarily leads to memorization rather than generalization. Through comprehensive experiments, our proposed model LIMO demonstrates unprecedented performance and efficiency in mathematical reasoning. With merely 817 curated training samples, LIMO achieves 57.1% accuracy on the highly challenging AIME benchmark and 94.8% on MATH, improving the performance of previous strong SFT-based models from 6.5% to 57.1% on AIME and from 59.2% to 94.8% on MATH, while only using 1% of the training data required by previous approaches. Most remarkably, LIMO demonstrates exceptional out-of-distribution generalization, achieving 40.5% absolute improvement across 10 diverse benchmarks, outperforming models trained on 100x more data, directly challenging the prevailing notion that SFT inherently leads to memorization rather than generalization. Synthesizing these pioneering results, we propose the Less-Is-More Reasoning Hypothesis (LIMO Hypothesis): In foundation models where domain knowledge has been comprehensively encoded during pre-training, sophisticated reasoning capabilities can emerge through minimal but precisely orchestrated demonstrations of cognitive processes.
/r/MachineLearning
https://redd.it/1ile9nu
>We present a fundamental discovery that challenges our understanding of how complex reasoning emerges in large language models. While conventional wisdom suggests that sophisticated reasoning tasks demand extensive training data (often >100,000 examples), we demonstrate a striking phenomenon: complex mathematical reasoning abilities can be effectively elicited with surprisingly few examples. This finding challenges not only the assumption of massive data requirements but also the common belief that supervised fine-tuning primarily leads to memorization rather than generalization. Through comprehensive experiments, our proposed model LIMO demonstrates unprecedented performance and efficiency in mathematical reasoning. With merely 817 curated training samples, LIMO achieves 57.1% accuracy on the highly challenging AIME benchmark and 94.8% on MATH, improving the performance of previous strong SFT-based models from 6.5% to 57.1% on AIME and from 59.2% to 94.8% on MATH, while only using 1% of the training data required by previous approaches. Most remarkably, LIMO demonstrates exceptional out-of-distribution generalization, achieving 40.5% absolute improvement across 10 diverse benchmarks, outperforming models trained on 100x more data, directly challenging the prevailing notion that SFT inherently leads to memorization rather than generalization. Synthesizing these pioneering results, we propose the Less-Is-More Reasoning Hypothesis (LIMO Hypothesis): In foundation models where domain knowledge has been comprehensively encoded during pre-training, sophisticated reasoning capabilities can emerge through minimal but precisely orchestrated demonstrations of cognitive processes.
/r/MachineLearning
https://redd.it/1ile9nu
Reddit
From the MachineLearning community on Reddit
Explore this post and more from the MachineLearning community
FastAPI Guard - A FastAPI extension to secure your APIs
Hi everyone,
I've published FastAPI Guard some time ago:
Documentation: rennf93.github.io/fastapi-guard/
GitHub repo: github.com/rennf93/fastapi-guard
What is it?
FastAPI Guard is a security middleware for FastAPI that provides:
- IP whitelisting/blacklisting
- Rate limiting & automatic IP banning
- Penetration attempt detection
- Cloud provider IP blocking
- IP geolocation via IPInfo.io
- Custom security logging
- CORS configuration helpers
It's licensed under MIT and integrates seamlessly with FastAPI applications.
Comparison to alternatives:
-
-
-
-
Key differentiators:
- Combines multiple security layers in single middleware
- Automatic IP banning based on suspicious activity
- Built-in cloud provider detection
- Daily-updated IP geolocation database
- Production-ready configuration defaults
Target Audience:
FastAPI developers needing:
- Defense-in-depth security strategy
- IP-based access control
- Automated threat mitigation
- Compliance with geo-restriction requirements
- Penetration attempt monitoring
Feedback wanted
Thanks!
/r/Python
https://redd.it/1ilhbkk
Hi everyone,
I've published FastAPI Guard some time ago:
Documentation: rennf93.github.io/fastapi-guard/
GitHub repo: github.com/rennf93/fastapi-guard
What is it?
FastAPI Guard is a security middleware for FastAPI that provides:
- IP whitelisting/blacklisting
- Rate limiting & automatic IP banning
- Penetration attempt detection
- Cloud provider IP blocking
- IP geolocation via IPInfo.io
- Custom security logging
- CORS configuration helpers
It's licensed under MIT and integrates seamlessly with FastAPI applications.
Comparison to alternatives:
-
fastapi-security: Focuses more on authentication, while FastAPI Guard provides broader network-layer protection-
slowapi: Handles rate limiting but lacks IP analysis/geolocation features-
fastapi-limiter: Pure rate limiting without security features-
fastapi-auth: Authentication-focused without IP managementKey differentiators:
- Combines multiple security layers in single middleware
- Automatic IP banning based on suspicious activity
- Built-in cloud provider detection
- Daily-updated IP geolocation database
- Production-ready configuration defaults
Target Audience:
FastAPI developers needing:
- Defense-in-depth security strategy
- IP-based access control
- Automated threat mitigation
- Compliance with geo-restriction requirements
- Penetration attempt monitoring
Feedback wanted
Thanks!
/r/Python
https://redd.it/1ilhbkk
GitHub
GitHub - rennf93/fastapi-guard: A security library for FastAPI that provides middleware to control IPs, log requests, and detect…
A security library for FastAPI that provides middleware to control IPs, log requests, and detect penetration attempts. It integrates seamlessly with FastAPI to offer robust protection against vario...
Django REST framework, Django Ninja, FastAPI with Pydantic, and Golang API serialization performance.
A few months ago I wrote a post about comparing the API serialization performance retrieve large amount of records in Django REST Framework, Django Ninja, and Golang. I provided a step-by-step guide in optimization for Django as well as dockerized example for each framework tested. A lot of you liked it, and one common ask was, how does FastAPI compared.
It's taken me a while to sit down and work on this again, but I have now included a dockerized example of FastAPI with SQLAlchemy and Pydantic on the same set of data models with exact same API for comparison. I also added a dockerized example of Locust to do testing now. You can check it out and test it for yourself: https://github.com/oscarychen/building-efficient-api
I gotta say I was expecting FastAPI with Pydantic to perform not far behind Django Ninja, because the serialization of response data mechanism was expected to be similar. I am actually surprised FastAPI is quite a bit faster. Obviously, if we strip parsing response payload through the schema/serializer, Django REST Framework and Django Ninja are a lot faster, but typically on most APIs we would have those mechanism as part of response data parsing, and FastAPI does it significantly
/r/django
https://redd.it/1ilp876
A few months ago I wrote a post about comparing the API serialization performance retrieve large amount of records in Django REST Framework, Django Ninja, and Golang. I provided a step-by-step guide in optimization for Django as well as dockerized example for each framework tested. A lot of you liked it, and one common ask was, how does FastAPI compared.
It's taken me a while to sit down and work on this again, but I have now included a dockerized example of FastAPI with SQLAlchemy and Pydantic on the same set of data models with exact same API for comparison. I also added a dockerized example of Locust to do testing now. You can check it out and test it for yourself: https://github.com/oscarychen/building-efficient-api
I gotta say I was expecting FastAPI with Pydantic to perform not far behind Django Ninja, because the serialization of response data mechanism was expected to be similar. I am actually surprised FastAPI is quite a bit faster. Obviously, if we strip parsing response payload through the schema/serializer, Django REST Framework and Django Ninja are a lot faster, but typically on most APIs we would have those mechanism as part of response data parsing, and FastAPI does it significantly
/r/django
https://redd.it/1ilp876
Reddit
From the django community on Reddit
Explore this post and more from the django community
Two Fast Auth - A FastAPI extension to implement 2FA
Hi everyone,
I've published Two Fast Auth:
Documentation: rennf93.github.io/two-fast-auth/
GitHub repo: github.com/rennf93/two-fast-auth
What is it?
Two Fast Auth is a FastAPI middleware that provides seamless two-factor authentication implementation with:
- QR code generation for authenticator apps
- Time-based one-time password (TOTP) verification
- Secure recovery code management
- Optional secret encryption
- Middleware integration for route protection
- Production-ready configuration defaults
MIT licensed and designed specifically for FastAPI applications.
Comparison to alternatives:
-
-
-
Key differentiators:
- Native FastAPI middleware implementation
- Built-in QR code generation endpoint
- Recovery code lifecycle management
- Fernet encryption for secret storage
- Zero-configuration defaults for quick setup
- Active maintenance with production use cases
Target Audience:
FastAPI developers needing:
- Quick 2FA implementation without vendor lock-in
- Compliance with security standards requiring MFA
- Recovery code workflows for end-users
- Encrypted secret storage capabilities
- QR code-based authenticator app setup
Feedback wanted :)
Thanks!
/r/Python
https://redd.it/1ilhnfm
Hi everyone,
I've published Two Fast Auth:
Documentation: rennf93.github.io/two-fast-auth/
GitHub repo: github.com/rennf93/two-fast-auth
What is it?
Two Fast Auth is a FastAPI middleware that provides seamless two-factor authentication implementation with:
- QR code generation for authenticator apps
- Time-based one-time password (TOTP) verification
- Secure recovery code management
- Optional secret encryption
- Middleware integration for route protection
- Production-ready configuration defaults
MIT licensed and designed specifically for FastAPI applications.
Comparison to alternatives:
-
fastapi-jwt-auth: Focuses on JWT authentication without native 2FA-
python-otp: Provides OTP generation but no framework integration-
authlib: General-purpose auth library without FastAPI-specific middlewareKey differentiators:
- Native FastAPI middleware implementation
- Built-in QR code generation endpoint
- Recovery code lifecycle management
- Fernet encryption for secret storage
- Zero-configuration defaults for quick setup
- Active maintenance with production use cases
Target Audience:
FastAPI developers needing:
- Quick 2FA implementation without vendor lock-in
- Compliance with security standards requiring MFA
- Recovery code workflows for end-users
- Encrypted secret storage capabilities
- QR code-based authenticator app setup
Feedback wanted :)
Thanks!
/r/Python
https://redd.it/1ilhnfm
GitHub
GitHub - rennf93/two-fast-auth: FastAPI middleware that provides seamless two-factor authentication implementation. It integrates…
FastAPI middleware that provides seamless two-factor authentication implementation. It integrates with FastAPI to offer robust 2FA protection for your application routes. - rennf93/two-fast-auth
Unknown field(s) (usablepassword) specified for CustomUser. Check fields/fieldsets/exclude attributes of class CustomUserAdmin.
I inherited a CustomUser class from AbstractUser like this:
class CustomUser(AbstractUser):
passclass CustomUser(AbstractUser):
pass
Here is the admin for this class:
from django.contrib import admin
from django.contrib.auth import getusermodel
from django.contrib.auth.admin import UserAdmin
from .forms import CustomUserChangeForm, CustomUserCreationForm
CustomUser = getusermodel()
class CustomUserAdmin(UserAdmin):
addform = CustomUserCreationForm
form = CustomUserChangeForm
model = CustomUser
listdisplay = [
"email",
"username",
"issuperuser",
]
admin.site.register(CustomUser, CustomUserAdmin)
The forms only define email and username:
class
/r/djangolearning
https://redd.it/1ile16j
I inherited a CustomUser class from AbstractUser like this:
class CustomUser(AbstractUser):
passclass CustomUser(AbstractUser):
pass
Here is the admin for this class:
from django.contrib import admin
from django.contrib.auth import getusermodel
from django.contrib.auth.admin import UserAdmin
from .forms import CustomUserChangeForm, CustomUserCreationForm
CustomUser = getusermodel()
class CustomUserAdmin(UserAdmin):
addform = CustomUserCreationForm
form = CustomUserChangeForm
model = CustomUser
listdisplay = [
"email",
"username",
"issuperuser",
]
admin.site.register(CustomUser, CustomUserAdmin)
The forms only define email and username:
class
/r/djangolearning
https://redd.it/1ile16j
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community
[R] Your AI can’t see gorillas: A comparison of LLMs’ ability to perform exploratory data analysis
https://chiraaggohel.com/posts/llms-eda/
/r/MachineLearning
https://redd.it/1iljqve
https://chiraaggohel.com/posts/llms-eda/
/r/MachineLearning
https://redd.it/1iljqve
Chiraaggohel
Your AI can’t see gorillas – Chiraag Gohel
A comparison of LLMs’ ability to perform exploratory data analysis
Monday Daily Thread: Project ideas!
# 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"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) 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](https://www.youtube.com/watch?v=a37BL0stIuM)
# 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](https://www.youtube.com/watch?v=9P5MY_2i7K8)
## 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](https://automatetheboringstuff.com/2e/chapter9/)
Let's help each other grow. Happy
/r/Python
https://redd.it/1ilt1is
# 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"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) 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](https://www.youtube.com/watch?v=a37BL0stIuM)
# 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](https://www.youtube.com/watch?v=9P5MY_2i7K8)
## 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](https://automatetheboringstuff.com/2e/chapter9/)
Let's help each other grow. Happy
/r/Python
https://redd.it/1ilt1is
YouTube
Build & Integrate your own custom chatbot to a website (Python & JavaScript)
In this fun project you learn how to build a custom chatbot in Python and then integrate this to a website using Flask and JavaScript.
Starter Files: https://github.com/patrickloeber/chatbot-deployment
Get my Free NumPy Handbook: https://www.python-engi…
Starter Files: https://github.com/patrickloeber/chatbot-deployment
Get my Free NumPy Handbook: https://www.python-engi…
Inviting Collaborators for a Differentiable Geometric Loss Function Library
Hello,
I am a grad student at Stanford, working on shape optimization for aircraft design.
I am looking for collaborators on a project for creating a differentiable geometric loss function library in pytorch.
I put a few initial commits on a repository here to give an idea of what things might look like:
Github repo
Inviting collaborators on twitter
/r/Python
https://redd.it/1ilzsly
Hello,
I am a grad student at Stanford, working on shape optimization for aircraft design.
I am looking for collaborators on a project for creating a differentiable geometric loss function library in pytorch.
I put a few initial commits on a repository here to give an idea of what things might look like:
Github repo
Inviting collaborators on twitter
/r/Python
https://redd.it/1ilzsly
GitHub
GitHub - atharvaaalok/geosimilarity: Differentiable curve and surface similarity measures.
Differentiable curve and surface similarity measures. - atharvaaalok/geosimilarity
Question about store environment variables
I am trying to store secret environment variables. All the tutorials I have checked tell me to download python-datoenv and create a .env file. My file is called .flaskenv. Is that technically wrong? I followed Miguel's mega tutorial and he told me to call that file .flaskenv.
/r/flask
https://redd.it/1ilmnpc
I am trying to store secret environment variables. All the tutorials I have checked tell me to download python-datoenv and create a .env file. My file is called .flaskenv. Is that technically wrong? I followed Miguel's mega tutorial and he told me to call that file .flaskenv.
/r/flask
https://redd.it/1ilmnpc
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
I made Versioneer work with Hatchling and pdm build backends
version-pioneer is a fork of Versioneer that supports Hatchling and pdm build backends.
The reason I hesitated for so long to switch from setuptools to hatchling etc. was Versioneer. I believe versioning system should be independent from the backend you use so you can easily migrate. Not only that you have to learn a new system, but also they don't work the same way. For example, I noticed other VCS versioning systems do not support dynamic version resolution in editable installs, which means while developing you will often get incorrect version.
### What My Project Does:
- Highly customisable: It's an easy-to-read script. Literally a simple Python script in which you can customise the version format or anything you need.
- 🐍 Runs with Python 3.8+
- ❌📦 No dependencies like package, config file etc. It runs with one Python file.
- ⭕ Works with any build backend with hooks. (Supports setuptools, hatchling, pdm)
- 🦀 Works with any language, not just Python.
- Version format
- CLI makes it easy to compute the version without vendoring anything in the
/r/Python
https://redd.it/1im12r8
version-pioneer is a fork of Versioneer that supports Hatchling and pdm build backends.
The reason I hesitated for so long to switch from setuptools to hatchling etc. was Versioneer. I believe versioning system should be independent from the backend you use so you can easily migrate. Not only that you have to learn a new system, but also they don't work the same way. For example, I noticed other VCS versioning systems do not support dynamic version resolution in editable installs, which means while developing you will often get incorrect version.
### What My Project Does:
- Highly customisable: It's an easy-to-read script. Literally a simple Python script in which you can customise the version format or anything you need.
- 🐍 Runs with Python 3.8+
- ❌📦 No dependencies like package, config file etc. It runs with one Python file.
- ⭕ Works with any build backend with hooks. (Supports setuptools, hatchling, pdm)
- 🦀 Works with any language, not just Python.
- Version format
"digits" generates digits-only version string which is useful for multi-language projects, Chrome Extension, etc. because their versioning standard is different.- CLI makes it easy to compute the version without vendoring anything in the
/r/Python
https://redd.it/1im12r8
GitHub
GitHub - kiyoon/version-pioneer: Versioneer fork with hatchling, pdm support with useful CLI. Manage git tag-based version for…
Versioneer fork with hatchling, pdm support with useful CLI. Manage git tag-based version for any project. - kiyoon/version-pioneer
P Inviting Collaborators for a Differentiable Geometric Loss Function Library
Hello,
I am a grad student at Stanford, working on shape optimization for aircraft design.
I am looking for collaborators on a project for creating a differentiable geometric loss function library in pytorch.
I put a few initial commits on a repository here to give an idea of what things might look like:
Github repo
Inviting collaborators on twitter
/r/MachineLearning
https://redd.it/1ilzqdb
Hello,
I am a grad student at Stanford, working on shape optimization for aircraft design.
I am looking for collaborators on a project for creating a differentiable geometric loss function library in pytorch.
I put a few initial commits on a repository here to give an idea of what things might look like:
Github repo
Inviting collaborators on twitter
/r/MachineLearning
https://redd.it/1ilzqdb
GitHub
GitHub - atharvaaalok/geosimilarity: Differentiable curve and surface similarity measures.
Differentiable curve and surface similarity measures. - atharvaaalok/geosimilarity
HTTP queries parameters to MongoDB Query Language converter
I did develop a Python module for my company based on Regex to convert HTTP queries parameters sent from frontend app (React & Angular mainly) to our backend (FastAPI) in MongoDB Query Language (MQL). This way, frontend devs can easilly make specific queries without asking the backend devs.
It is working pretty well for a couple of years but it became pretty hard to maintain and update. I'm also asking myself, can I improve it ? Here is a couple of exemple that I've build over the years:
http://localhost:8000/api/v1/company?filter=category==507f1f77bcf86cd799439011^createdat=BETWEEN(2024-01-01,2025-06-30)^nbemployee>10
# Output in Python
from query import MongoQueryManager as mqm
query = mqm(filter="category==507f1f77bcf86cd799439011^createdat=BETWEEN(2024-01-01,2025-06-30)^nbemployee>10", page=0, limit=100, orderdir="asd", orderby="createdat", excludedkeys=)
print(query.mongoargs)
{'filter': {'$and': [{'category': '507f1f77bcf86cd799439011'}, {'createdat': {'$gte': 1704063600.0, '$lte': 1751234400.0}}, {'nbemployee': {'$gt': 10}}]}, 'sort': [('createdat', -1)], 'skip': 0}
Note :
There is some limitation, we can only put 3 logical operator if there is AND and OR at the same time. Example :
/r/Python
https://redd.it/1im5i4s
I did develop a Python module for my company based on Regex to convert HTTP queries parameters sent from frontend app (React & Angular mainly) to our backend (FastAPI) in MongoDB Query Language (MQL). This way, frontend devs can easilly make specific queries without asking the backend devs.
It is working pretty well for a couple of years but it became pretty hard to maintain and update. I'm also asking myself, can I improve it ? Here is a couple of exemple that I've build over the years:
http://localhost:8000/api/v1/company?filter=category==507f1f77bcf86cd799439011^createdat=BETWEEN(2024-01-01,2025-06-30)^nbemployee>10
# Output in Python
from query import MongoQueryManager as mqm
query = mqm(filter="category==507f1f77bcf86cd799439011^createdat=BETWEEN(2024-01-01,2025-06-30)^nbemployee>10", page=0, limit=100, orderdir="asd", orderby="createdat", excludedkeys=)
print(query.mongoargs)
{'filter': {'$and': [{'category': '507f1f77bcf86cd799439011'}, {'createdat': {'$gte': 1704063600.0, '$lte': 1751234400.0}}, {'nbemployee': {'$gt': 10}}]}, 'sort': [('createdat', -1)], 'skip': 0}
Note :
507f1f77bcf86cd799439011 is an ObjectId (specific to MongoDB).There is some limitation, we can only put 3 logical operator if there is AND and OR at the same time. Example :
arg1=1 AND arg2=2 AND arg3=3 OR arg4=4. I never find a way to code something stable/r/Python
https://redd.it/1im5i4s
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
SQLalchemy is driving me nuts
I want to set all timestamps in DB with timezone utc, but my DB uses its own local time as timezone instead. Can anyone spot what I am doing wrong?
My sqlalchemy defs looks like this.
import sqlalchemy as sa
import sqlalchemy.orm as so
from datetime import datetime, timezone
timestamp: so.Mapped[datetime] = so.mapped_column(sa.DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
When I pull the data from the DB I get something like this, where timezone seems to be the server timezone:
datetime.datetime(2025, 2, 9, 23, 33, 59, 666407, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600)))
While I would want something like this:
datetime.datetime(2025, 2, 10, 12, 31, 56, 422389, tzinfo=datetime.timezone.utc)
/r/flask
https://redd.it/1im57ij
I want to set all timestamps in DB with timezone utc, but my DB uses its own local time as timezone instead. Can anyone spot what I am doing wrong?
My sqlalchemy defs looks like this.
import sqlalchemy as sa
import sqlalchemy.orm as so
from datetime import datetime, timezone
timestamp: so.Mapped[datetime] = so.mapped_column(sa.DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
When I pull the data from the DB I get something like this, where timezone seems to be the server timezone:
datetime.datetime(2025, 2, 9, 23, 33, 59, 666407, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600)))
While I would want something like this:
datetime.datetime(2025, 2, 10, 12, 31, 56, 422389, tzinfo=datetime.timezone.utc)
/r/flask
https://redd.it/1im57ij
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
A Modern Python Repository Template with UV and Just
Hey folks, I wanted to share a Python repository template I've been using recently. It's not trying to be the ultimate solution, but rather a setup that works well for my needs and might be useful for others.
What My Project Does
It's a repository template that combines several modern Python tools, with a focus on speed and developer experience:
\- UV for package management
\- Just as a command runner
\- Ruff for linting and formatting
\- Mypy for type checking
\- Docker support with a multi-stage build
\- GitHub Actions CI/CD setup
The main goal was to create a clean starting point that's both fast and maintainable.
Target Audience
This template is meant for developers who want a production-ready setup but don't need all the bells and whistles of larger templates.
Comparison
The main difference from other templates is the use of Just instead of Make as the command runner. While this means an extra installation step, Just offers several advantages, such as a cleaner syntax, better dependency handling and others.
I also chose UV over pip for package management, but at this point I don't consider this as something unusual in the Python ecosystem.
You can find the template here: https://github.com/GiovanniGiacometti/python-repo-template
Happy to hear your thoughts and suggestions for improvement!
/r/Python
https://redd.it/1ime8ja
Hey folks, I wanted to share a Python repository template I've been using recently. It's not trying to be the ultimate solution, but rather a setup that works well for my needs and might be useful for others.
What My Project Does
It's a repository template that combines several modern Python tools, with a focus on speed and developer experience:
\- UV for package management
\- Just as a command runner
\- Ruff for linting and formatting
\- Mypy for type checking
\- Docker support with a multi-stage build
\- GitHub Actions CI/CD setup
The main goal was to create a clean starting point that's both fast and maintainable.
Target Audience
This template is meant for developers who want a production-ready setup but don't need all the bells and whistles of larger templates.
Comparison
The main difference from other templates is the use of Just instead of Make as the command runner. While this means an extra installation step, Just offers several advantages, such as a cleaner syntax, better dependency handling and others.
I also chose UV over pip for package management, but at this point I don't consider this as something unusual in the Python ecosystem.
You can find the template here: https://github.com/GiovanniGiacometti/python-repo-template
Happy to hear your thoughts and suggestions for improvement!
/r/Python
https://redd.it/1ime8ja
GitHub
GitHub - GiovanniGiacometti/python-repo-template: A Python template repository, featuring Just and UV
A Python template repository, featuring Just and UV - GiovanniGiacometti/python-repo-template
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/1iml55r
# 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/1iml55r
Discord
Join the Python Discord Server!
We're a large community focused around the Python programming language. We believe that anyone can learn to code. | 412982 members
Dynamic Templates help
Hello everyone.
I'm working on a project but I'm stuck in a part and I'm unsure on how to proceed on it.
I have a screen on my website where you're supposed to select an object, a Date based on said object and choose which action to take on that object and date.
I'd like to make it in such way that, if the user selects a Date from object A, that Actions appear or disappear based on whenever or not that object at that date has already done that action (it appears whenever A on Jan 09 has already done said action or not).
I already have a system by which I determine whenever that object has gone through that action at certain dates (just does an AND to a predetermined value), but I can't figure out how to change the actions list so that whenever the user chooses a Date on it , it swaps the value of A at that date and changes what values it should display.
If you could give me any suggestions I'd greatly appreciate it.
Thanks!
/r/djangolearning
https://redd.it/1iml37f
Hello everyone.
I'm working on a project but I'm stuck in a part and I'm unsure on how to proceed on it.
I have a screen on my website where you're supposed to select an object, a Date based on said object and choose which action to take on that object and date.
I'd like to make it in such way that, if the user selects a Date from object A, that Actions appear or disappear based on whenever or not that object at that date has already done that action (it appears whenever A on Jan 09 has already done said action or not).
I already have a system by which I determine whenever that object has gone through that action at certain dates (just does an AND to a predetermined value), but I can't figure out how to change the actions list so that whenever the user chooses a Date on it , it swaps the value of A at that date and changes what values it should display.
If you could give me any suggestions I'd greatly appreciate it.
Thanks!
/r/djangolearning
https://redd.it/1iml37f
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community
How do you self learn to make production ready applications
Hi all,
I am a software engineer with around 2.7 years of experience. I had to work on a non technical repetitive task for like a year and the rest of the time I was either working on a project making small changes or I was on the bench.
I recently got into Django and my question is how do people self learn. Let's say I watch a tutorial but I'm always stuck when I start to make a self project. Without the guidance of someone how do I know what are the best practices. Also when working on a client project one has access to paid services that they need to integrate. How do I get the same learning curve while working on personal projects?
I would really appreciate some tips from people who self learned the django on how they approach a project. Or any suggestions on becoming a good programmer even if they're not related to Django. Please be kind 🙏
Tldr: I guess what I'm looking for is how do people who self learn become pro in a language and how do they keep themselves up to dated.
/r/django
https://redd.it/1imc9y5
Hi all,
I am a software engineer with around 2.7 years of experience. I had to work on a non technical repetitive task for like a year and the rest of the time I was either working on a project making small changes or I was on the bench.
I recently got into Django and my question is how do people self learn. Let's say I watch a tutorial but I'm always stuck when I start to make a self project. Without the guidance of someone how do I know what are the best practices. Also when working on a client project one has access to paid services that they need to integrate. How do I get the same learning curve while working on personal projects?
I would really appreciate some tips from people who self learned the django on how they approach a project. Or any suggestions on becoming a good programmer even if they're not related to Django. Please be kind 🙏
Tldr: I guess what I'm looking for is how do people who self learn become pro in a language and how do they keep themselves up to dated.
/r/django
https://redd.it/1imc9y5
Reddit
From the django community on Reddit
Explore this post and more from the django community
Inherit from "dict" or "UserDict"?
I'm working on a project where we need to integrate a dictionary with a ttk.Treeview. The easiest approach would have been to handle data and visualization separately, but due to project requirements, we opted for a combined structure where both are tightly linked.
The idea is straightforward in theory: any change to the dictionary should be reflected in the Treeview, and any modification in the Treeview should update the dictionary. To achieve this, we're implementing the most efficient communication path between the data structure and its visualization within a single class.
Our initial plan was to intercept accesses using __getitem__, __setitem__, and __delitem__ by inheriting directly from "dict". However, a teammate suggested we should use "UserDict" from "collections" instead. We did a quick switch with the little code we have so far, and in practice, both approaches seem to work exactly the same.
That said, how can we be sure which one is the better choice for extending dictionary functionality?
This has sparked some minor disagreements in our team. ChatGPT leans towards "UserDict", but some of us prefer minimizing intermediaries to ensure efficiency stays "bare-metal," if you know what I mean.
/r/Python
https://redd.it/1imhrqa
I'm working on a project where we need to integrate a dictionary with a ttk.Treeview. The easiest approach would have been to handle data and visualization separately, but due to project requirements, we opted for a combined structure where both are tightly linked.
The idea is straightforward in theory: any change to the dictionary should be reflected in the Treeview, and any modification in the Treeview should update the dictionary. To achieve this, we're implementing the most efficient communication path between the data structure and its visualization within a single class.
Our initial plan was to intercept accesses using __getitem__, __setitem__, and __delitem__ by inheriting directly from "dict". However, a teammate suggested we should use "UserDict" from "collections" instead. We did a quick switch with the little code we have so far, and in practice, both approaches seem to work exactly the same.
That said, how can we be sure which one is the better choice for extending dictionary functionality?
This has sparked some minor disagreements in our team. ChatGPT leans towards "UserDict", but some of us prefer minimizing intermediaries to ensure efficiency stays "bare-metal," if you know what I mean.
/r/Python
https://redd.it/1imhrqa
Reddit
From the Python community on Reddit
Explore this post and more from the Python community