Tag: Python
-
if __name__ == ‘__main__’ vs Click: Package Entry Points
Entry points broke my script imports. Here's what changes when you migrate from if __name__ == '__main__' to Click with real migration pitfalls.
-
Python list vs tuple vs set: Read/Write Speed Benchmark
Compare Python list, tuple, and set performance with benchmarks revealing read/write speeds and when each data structure shines in real code.
-
Pillow to OpenCV: 3.4x Faster Image Load in Production
Pillow's imread took 800ms per image. OpenCV cut it to 240ms. Here's the color space trap, dtype bug, and EXIF hell that break every migration.
-
Pandas Time Series Resample: OHLC 14x Faster Than Custom
Pandas resample OHLC beats custom groupby 14x faster for time series aggregation. Discover why built-in wins and when to use which method.
-
Python weakref for Cache Systems: Prevent Memory Leaks
Stop cache memory leaks with Python weakref. WeakValueDictionary auto-evicts unused entriesโsee real benchmarks and production patterns.
-
Q-Learning from Scratch: 50-Line Agent Beats Random by 94%
Write a 50-line Q-Learning agent that beats random policy by 94% on FrozenLake. Hyperparameter mistakes, convergence curves, and why it fails on CartPole.
-
uv vs pip vs Poetry: 50+ Package Install Speed Test
uv installs 57 packages in 12 seconds vs pip's 152 seconds. Real benchmarks, CI results, and when Poetry's slow resolver actually saves you.
-
multiprocessing vs concurrent.futures: 2.1x Speed Gap
ProcessPoolExecutor beat multiprocessing.Pool by 2.1x on 10k tasksโuntil I fixed one config. Real benchmarks, chunking overhead, shared memory tradeoffs.