python

Back Open Paginator
23.02.2026 17:59
mopicmp (@mopicmp@mastodon.social)

Python Tip: bisect for Sorted Insert

import bisect
scores = [60, 70, 80, 90]
bisect.insort(scores, 75)
# [60, 70, 75, 80, 90] — O(log n) search

bisect module maintains sorted lists efficiently. O(log n) search + O(n) insert beats O(n log n)...

raccoonette.gumroad.com/l/Pyth




Show Original Post


23.02.2026 17:59
mopicmp (@mopicmp@mastodon.social)

Python Tip: os.scandir() Speed

import os
# 20x faster than os.listdir() for stat operations
for entry in os.scandir('/path'):
if entry.is_file():
print(entry.name, entry.stat().st_size)

os.scandir() caches file metadata during iteration. Up to 20x faster than listdir() + stat() calls.

raccoonette.gumroad.com/l/Pyth




Show Original Post


23.02.2026 17:37
driscollis (@driscollis@mastodon.social)

Need to know what packages you have installed using uv?

You can try this command:

uv pip list

You should see something like this:





Show Original Post


23.02.2026 17:30
Reuven (@Reuven@fosstodon.org)

A file you're loading into #Python #Pandas uses weird strings for missing values? Use the na_values parameter in read_* methods:

pd.read_csv(f, na_values='.')
pd.read_csv(f, na_values=['.', '*']) # multiple
pd.read_csv(f, na_values={'a':'.', 'b':'*'}) # per column





Show Original Post


23.02.2026 17:28
objects (@objects@fe.disroot.org)

Does the concept behind #python #httpx.Auth make sense?

Auth instances are responsible for setting up an Authorization header (or equivalent) but in some cases they might need to refresh their tokens or make other HTTP requests. httpx facilitates this by making Auth instances generators, and treating all but last yielded values as auth-related requests, and only the last one is the authorized user request.

Except I haven’t seen a library using this mechanism - all of them have their own inner httpx.Client instances

#programming




Show Original Post


23.02.2026 17:01
PythonPeak (@PythonPeak@mastodon.social)

How to Stop Float Equality Bugs

0.1 + 0.2 is not 0.3 in Python.

#python #float #precision #bug #howto #math

youtube.com/watch?v=dzMOOFhL3X0




Show Original Post


23.02.2026 16:56
HaraldKi (@HaraldKi@nrw.social)

More observations about checked vs. unchecked exceptions and why unchecked exceptions should not be called "exception". I rather suggest "explainer". Thy explain why an operation could not be performed.

miamao.de/blog/2026-02/23.When

#exception #uncheckedException #Java #TypeScript #Python #Rust




Show Original Post


23.02.2026 16:52
feed (@feed@igeek.gamer-geek-news.com)

🤖 Agentic AI with multi-model framework using Hugging Face smolagents on AWS

Hugging Face smolagents is an open source Python library designed to make it straightforward to build and run agents using a few lines of code. We will show you how to build an agentic AI solution ...

📰 Source: Artificial Intelligence
🔗 Link: https://aws.amazon.com/blogs/machine-learning/agentic-ai-with-multi-model-framework-using-hugging-face-smolagents-on-aws/

#AI #ArtificialIntelligence #Python




Show Original Post


23.02.2026 16:35
ham_jansen (@ham_jansen@mastodon.online)

Run a SQL query twice. Get different row orders. That's not a bug.

Databases optimize execution based on indexes, data volume, and memory. Those optimizations can change between queries.

If order matters, you need ORDER BY. And here's where SQL beats Python: mixed sort directions in one line.

ORDER BY signup_date DESC, name ASC

In Python, that requires cmp_to_key or multiple sorting passes. SQL handles it cleanly.

jamalhansen.com/blog/order-by-

#SQL #Python #DuckDB #DataScience #Programming




Show Original Post


23.02.2026 16:30
chribonn (@chribonn@twit.social)

AG (Retrieval Augmented Generation) is the solution. Here's how to build your own RAG server from scratch using ollama, Open WebUI and Chroma DB!

✅ Document processing ✅ Vector embeddings ✅ Smart retrieval ✅ Production-ready API

Tutorial 👉 medium.com/@chribonn/how-to-cr

#RetrievalAugmentedGeneration #RAG #AIEngineering #LLM #Python #TTMO #OpenSource #AI




Show Original Post


23.02.2026 16:30
chribonn (@chribonn@twit.social)

I walk through the Python Install Manager for Windows (pymanager). If you have older Python solutions, you should first:

1. Note of the Python versions associated with them.
2. Uninstall the python instals.

After install pymanager and if need be, recreate the venv.

Leave comment for tutorial.

youtu.be/v5hipvLeo2E

#TTMO #python #PythonInstallManager #PythonOnWindows #pyManager




Show Original Post


23.02.2026 16:18
Posit (@Posit@fosstodon.org)

posit::conf(2026) call for talks may be over, but there are still many #RStats & #Python events where you can submit! Maybe we'll see you there:

🇬🇭 Ghana R Conference (Jul 9-10, Virtual): Feb 25 ghana-rusers.org
🐍 SciPy (Jul 13-19, Minneapolis, MN): Feb 25 pretalx.com/scipy-2026/cfp





Show Original Post


1 ...435 436 437 438 439 440 441 442 443 444 445 ...1590
UP