pythoncommentsinterpreterinterpreted-language

Do comments slow down an interpreted language?


I use Python, but it could apply to other interpreted languages too (Ruby, PHP, JavaScript).

According to my understanding of an interpreter, it reads programs in as strings and then converts those into code. Every time it parses a comment, that is wasted time.

Is this the case? Is there some convention for comments in interpreted languages, or is it negligible?


Solution

  • For the case of Python, source files are compiled before being executed (the .pyc files), and the comments are stripped in the process. So comments could slow down the compilation time if you have gazillions of them, but they won't impact the execution time.