Possible Duplicate:
Do comments slow down an interpreted language?
Will there be noticeable performance degradation in the execution of a large .py file if more than 75% of the lines of code are properly commented?
Possible Duplicate:
Do comments slow down an interpreted language?
Will there be noticeable performance degradation in the execution of a large .py file if more than 75% of the lines of code are properly commented?
Copyright © 2021 Jogjafile Inc.
No
When you run python, the first step is to convert to bytecode, which is what those
.pycfiles are. Comments are removed from these, so it won't matter*.If you run with the
-Oor-OOoption, python will produce "optimized"pyofiles, which are negligibly faster, if faster at all. The main difference is that:-Oassertion are removed,-OOoption, the__doc__strings are stripped out. Given that those are sometimes needed, running with-OOisn't recommended.* it's been pointed out below that
.pycfiles are only saved for modules. Thus the top-level executable must be recompiled every time it's run. This step could slow down a massive python executable. In practice, most of the code should reside in modules, making this a non-issue.