目录
This page is devoted to various tips and tricks that help improve the performance of your Python programs. Wherever the information comes from someone else, I've tried to identify the source.
Python has changed in some significant ways since I first wrote my "fast python" page in about 1996, which means that some of the orderings will have changed. I migrated it to the Python wiki in hopes others will help maintain it.
Note: You should always test these tips with your application and the version of Python you intend to use and not just blindly accept that one method is faster than another. Good suggestions on profiling your python code are found here (archived version):
Also new since this was originally written are packages like , , and , which can dramatically improve your application's performance by making it easier to push performance-critical code into C or machine language.
Other Versions
-
Russian:
Overview: Optimize what needs optimizing
You can only know what makes your program slow after first getting the program to give correct results, then running it to see if the correct program is slow.