Category: Python Tips
-
gc.collect() Slows Python 32%: When Manual GC Hurts
Manual gc.collect() slowed my pipeline 32%. Here's when Python's GC heuristics beat your intuition โ and the rare cases where you should override them.
-
import * in Functions: UnboundLocalError & Namespace Fix
Learn why `import *` inside functions causes UnboundLocalError and discover the namespace mechanics behind this Python gotcha with practical fixes.
-
tracemalloc vs memray vs Py-Spy: Profiler Overhead Cost
Compare Python memory profilers: tracemalloc, memray, and Py-Spy overhead costs. Which one is fastest? Performance benchmarks reveal the winner.
-
Virtual Environments Broke My First Django App: Skip Them
Virtual environments add 45% cognitive load to beginners who won't hit dependency conflicts for months. Here's when to skip venv and when to adopt it.
-
unittest to pytest Migration: Fixtures and Async Patterns
Migrate unittest to pytest with practical fixture examples and async testing patterns. Learn parametrization, mocking, and real-world refactoring tips.
-
Python __slots__: 40% Memory Savings and Interview Gotchas
Cut Python class memory by 40% with __slots__โplus the 3 gotchas interviewers use to catch candidates who only read the docs.
-
Python 3.13 Free-Threading: GIL Removal Benchmarks
Python 3.13 free-threading removes the GIL for real parallel CPU execution. Benchmarks, compatibility gotchas, when it beats multiprocessing.
-
functools.cache vs lru_cache: When 40% Speed Costs Stability
functools.cache runs 40% faster than lru_cache but can crash production. Benchmark data shows when unbounded caching breaks.