Python-ஐ optimize செய்வது உண்மையான bottleneck-ஐ கண்டறிய profiling-உடன் தொடங்குகிறது — ஒருபோதும் யூகிக்காமல். Python-இன் interpreted, dynamic தன்மை அதை compiled languages-ஐ விட மெதுவாக ஆக்குகிறது, எனவே optimization சிறந்த algorithms, C-backed libraries-ஐ பயன்படுத்துதல், மற்றும் hot paths-இல் interpreter overhead-ஐ குறைப்பதில் கவனம் செலுத்துகிறது.
முதலில் profile செய்யவும்
import cProfile
cProfile.run("my_function()") # shows time spent per function call
