Optimizing Python starts with profiling to find the real bottleneck — never guessing. Python's interpreted, dynamic nature makes it slower than compiled languages, so optimization focuses on better algorithms, leveraging C-backed libraries, and reducing interpreter overhead in hot paths.
Profile first
import cProfile
cProfile.run("my_function()") # shows time spent per function call
# line-level profiling (third-party)
# pip install line_profiler → @profile decorator → kernprof -l -v script.py
