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
VJUPYTER DOWNLODE AND RUN IN VISUAL STUDIO COMMUNITY 2022

HOW TO RUN AND INSTALL JUPYTYER IN VISUAL STUDIO COOMUNITY 2022 SAME AS VS CODE?

/r/IPython
https://redd.it/1jdagv6
ETL completa com Python: Validando Dados e Planilhas de Excel para BI (Projeto end-to-end!)

Olá, pessoal!



Espero que todos estejam bem! Queria compartilhar um vídeo muito legal que pode ajudar a melhorar nossas habilidades em engenharia de dados. O vídeo é "ETL completa com Python: Validando Dados e Planilhas de Excel para BI (Projeto end-to-end!)". Confiram no link abaixo:



https://www.youtube.com/watch?v=JuOyNPjAer8



Aproveitem e bora aprender juntos!

/r/Python
https://redd.it/1jdkn65
To GeoDjango or not to GeoDjango

Hello everyone,

I need some insight here. I have an existing Django app using a MySQL database. One of the models that is defined here is called Location. To give you an idea, it just has a name (CharField) and description (TextField), so nothing fancy here.

I have the idea to extend the Location model with actual coordinates. The use case here would be to show where some objects are that have Location as foreign key, using spatial maps and interactive visualizations on the front-end.

I want to extend Location with both a single (x,y) coordinate and a field that defines some sort of bouding box like a polygon. The easiest way would be to use both PointFields and PolygonFields from GeoDjango. I found this implementation to be highly excessive for just the addition of two fields. Also, I'm unsure of changing my database engine django.db.backends.mysql to django.contrib.gis.db.backends.mysql just like that. I can see the benefits of using GeoDjango, but it feels overkill. On the other hand, using plain JSONFields or other fields that represent this data feels like a 'messy' way to solve this issue.

I'm wondering if anyone else has had the same or similar issue? What are your thoughts on this?

Thanks

/r/django
https://redd.it/1jdfzqm
Feedback Wanted: GenAnalyzer - Web App for Protein Sequence Analysis & Mutation Detection

Hello everyone,

I created a web application called GenAnalyzer, which simplifies the analysis of protein sequences, identifies mutations, and explores their potential links to genetic diseases. It integrates data from multiple sources like UniProt for protein sequences and ClinVar for mutation-disease associations.

The application is built using Python Flask for the web framework and Biopython for protein sequence analysis, allowing users to compare sequences and detect mutations.

This project is my graduate project, and I would be really grateful if I could find someone who would use it and provide feedback. Your comments, ratings, and criticism would be greatly appreciated as they’ll help me improve the tool.

You can check out the app here: GenAnalyzer Web App

Feel free to explore the source code and contribute on the GenAnalyzer GitHub Repository

Feel free to leave any feedback, suggestions, or even criticisms. I would be happy for any comments or ratings.

Thanks for your time, and I look forward to hearing your thoughts.

/r/flask
https://redd.it/1jdlp5k
DRF API url location

In Django we typically define our DRF endpoints with a prefix of '/api/'. For a project with multiple DRF apps, where do you define these. Do you define them in the core project folder or do you define each on within it's respective app folder?

/r/django
https://redd.it/1jdj449
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/1jdrtck
[P] I fine-tuned Qwen 2.5 Coder on a single repo and got a 47% improvement in code completion accuracy

Hey all,

Just wanted to share an interesting experiment I ran to see what kind of performance gains can be achieved by fine-tuning a coding model to code from a single repo.

**Tl;dr**: The fine-tuned model achieves a 47% improvement in the code completion task (tab autocomplete). Accuracy goes from 25% to 36% (exact match against ground truth) after a short training run of only 500 iterations on a single RTX 4090 GPU.

https://preview.redd.it/3borsuk1bape1.png?width=1063&format=png&auto=webp&s=8d9510517f3d04163b3ac6b1de6765158886e489

This is interesting because it shows that there are significant gains to be had by fine-tuning to your own code.

**Highlights of the experiment**:

* Model: qwen2.5-coder 14b, 4-bit quantized
* Training data: Svelte source files from this repo: [https://github.com/hcengineering/platform](https://github.com/hcengineering/platform)
* Unsloth for LoRA training with rank 16, 4096 sequence length
* GPU: single RTX 4090
* 500 iterations with effective batch size 8

/r/MachineLearning
https://redd.it/1jdiafd
What is the convention for and when it comes to OOP?

Is it a convention in Python that \
_ in class method or variable name signifies a private variable, while a _ signifies a protected variable?

I knew it was a convention to use it to signify that a variable or method wasn't to be used outside of the class, but I didn't know about this distinction of private and protected.

For context, I stumbled upon this question when Perplexity AI told me this was the case. I asked it to give me the sources for this but was unable to produce nothing outside a couple of blogs and articles.


So here I am asking the community, what do you think? I think it sounds interesting, to say the least. I have never though about using both __ and _ in the same piece of code, for the sake of consistency (I also thought it was discouraged), but now I am of the opinion that this distinction could actually be useful when designing more complex OOP systems.

/r/Python
https://redd.it/1jdtab6
I wrote a script to simulate this years March Madness

Here’s the code: https://gist.github.com/CoreyMSchafer/27fcf83e5a0e5a87f415ff19bfdd2a4c

Also made a YouTube walkthrough here: https://youtu.be/4TFQD0ok5Ao

The script uses the inverse of the seeds to weight the teams. There is commented out code that you can adjust to give seeds more/less of an advantage. If you’d like to weight each team individually, you could also add a power attribute to the Team dataclass and at those individually when instantiating the first round.

/r/Python
https://redd.it/1jdsi9u
str2speech: A wrapper for all the new TTS models being released

GitHub: str2speech

# What my project does

Makes it easier to use all the latest TTS models.

I currently support:

- Zyphra Zonos
- Sesame CSM-1B
- Kokoro-82M
- Suno's Bark
- and a few older MMS-TTS models from Facebook

I'll be adding more models soon, like Spark TTS.

# Target Audience

Everyone who's interested in trying out/comparing TTS models. Could be used in production by YouTubers, podcasters, etc. Should work reasonably well in Shell scripts too.

# Comparison

The closest project I can think of is coqui-ai tts. It's a much larger project (supporting xtts, bark, tortoise, and many more models), but it seems to be abandoned. They haven't added support for any models released in the last couple of months.

My project tries to support more modern models. I try to focus on the CLI and ease of use on Google colab.

# Usage

Installation is easy:

pip install str2speech


And so is usage, I think:

str2speech --text "Kokoro is nice" --model "kokoro"


More examples and full code available on GitHub: str2speech

/r/Python
https://redd.it/1jdrvwy
Building a Multi-Tenant Automation System in a Django CRM – Seeking Advice

Hi all,

I'm working on a SaaS CRM built with Django/DRF that centers around leads and deals, and I'm looking to implement a robust automation system. The idea is to allow for dynamic, multi-tenant automations that can be triggered by events on leads and deals, as well as scheduled tasks (like daily or weekly operations).

I'm using Django-tenants and django-q2

At a high level, the system should let users set up rules that include triggers, conditions, and actions, with everything stored in the database to avoid hardcoding. I'm considering a design that includes event-driven triggers (using Django signals or an equivalent) and a task queue for longer-running processes, but I'm curious about potential performance pitfalls and best practices when scaling these systems.

I'm interested in hearing from anyone who's built something similar or has experience with automations in a multi-tenant environment. Any advice, pitfalls to watch out for, or suggestions on design and architecture would be greatly appreciated!

Thanks in advance for your help.

/r/django
https://redd.it/1jdzkb8
PySide6 + Nuitka is very impressive (some numbers and feedback inside)

In preparation for releasing a new version of Flowkeeper I decided to try replacing PyInstaller with Nuitka. My main complaint about PyInstaller was that I could never make it work with MS Defender, but that's a topic for another time.

I've never complained about the size of the binaries that PyInstaller generated. Given that it had to bundle Python 3 and Qt 6, \~100MB looked reasonable. So you can imagine how surprised I was when instead of spitting out a usual 77MB for a standalone / portable Windows exe file it produced... a 39MB one! It is twice smaller, seemingly because Nuitka's genius C compiler / linker could shed unused Qt code so well.

Flowkeeper is a Qt Widgets app, and apart from typical QtCore, QtGui and QtWidgets it uses QtMultimedia, QtChart, QtNetwork, QtWebSockets and some other modules from PySide6_Addons. It also uses Fernet cryptography package, which in turn bundles hazmat. Finally, it includes a 10MB mp3 file, as well as \~2MB of images and fonts as resources. So all of that fits into a single self-contained 40MB exe file, which I find mighty impressive, especially if you start comparing it against Electron. Oh yes, and that's with the latest stable Python

/r/Python
https://redd.it/1je94cf
R Jagged Flash Attention Optimization

Meta researchers have introduced Jagged Flash Attention, a novel technique that significantly enhances the performance and scalability of large-scale recommendation systems. By combining jagged tensors with flash attention, this innovation achieves up to 9× speedup and 22× memory reduction compared to dense attention, outperforming even dense flash attention with 3× speedup and 53% better memory efficiency.


Read the full paper write up here: https://www.shaped.ai/blog/jagged-flash-attention-optimization

/r/MachineLearning
https://redd.it/1je93sv
Python Quirks I Secretly Like

Hi there,

I’ve always wanted to create YouTube content about programming languages, but I’ve been self-conscious about my voice (and mic, lol). Recently, I made a pilot video on the Zig programming language, and afterward, I met a friend here on Reddit, u/tokisuno, who has a great voice and offered to do the voiceovers.

So, we’ve put together a video on Python — I hope you’ll like it:

https://www.youtube.com/watch?v=DZtdkZV6hYM

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