Category: Python Tips
-
__post_init__ vs __new__ vs __init__: When Order Matters
Learn when to use __post_init__, __new__, or __init__ in Python dataclasses and classesโmaster initialization order to prevent subtle bugs.
-
list.append vs Comprehension vs deque: 100k Benchmark
Benchmark reveals why list comprehensions beat append() by 15% in Pythonโbut there's an even faster method for large datasets you should know.
-
Python 3.12 vs 3.13 JIT: 16% Faster or 2x Slower?
Python 3.13 JIT promises 16% speed gains, but real-world benchmarks reveal surprising slowdowns. Compare actual performance impacts here.
-
__del__ Cyclic References Leak Memory: 3 Patterns That Fail
Python's GC skips __del__ cyclesโproduction memory leaked 4GB in 3 days. Here's how weak refs fix parent-child, exception, and thread-local leaks.
-
Import Side Effects Break Tests: 4 Patterns That Pass Locally
Import side effects pass locally but break in CI. Here's how env vars, DB connections, and plugin registration fail when test order changes.
-
uv vs pip vs Poetry: Install Speed Test on 50+ Packages
pip took 68s, Poetry 227s, uv just 4s for 52 packages. Here's why the Rust-based installer wins for beginners โ and when to stick with Poetry.
-
Python Type Hints: runtime vs typing-only Annotations
Most Python type hints do nothing at runtime. See which annotations actually validate, real performance numbers, and the isinstance() trap with generics.