Do comments slow down an interpreted language?

后端 未结 11 2226
深忆病人
深忆病人 2020-12-01 09:59

I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript).

Am I slowing down the interpreter whenever

11条回答
  •  伪装坚强ぢ
    2020-12-01 10:46

    Having comments will slow down the startup time, as the scripts will get parsed into an executable form. However, in most cases comments don't slow down runtime.

    Additionally in python, you can compile the .py files into .pyc, which won't contain the comments (I should hope) - this means that you won't get a startup hit either if the script is already compiled.

提交回复
热议问题