Measure before optimizing
Performance optimization should begin with a real workload and a measurable target. Python provides tools such as timeit for small benchmarks and cProfile for understanding where a program spends its time.
Find the actual bottleneck
A program may look slow because of a Python loop while the real bottleneck is a database query or network request. Profiling prevents time being wasted optimizing code that contributes little to total execution time.
Optimize, then verify
After changing an implementation, measure again and run the test suite. An optimization that changes behavior or consumes much more memory may not be a real improvement.
Practice: benchmark two implementations of a small data-processing task and use a profiler to identify the slowest function.