更多的空格或更多的制表符是否需要更多的解释时间?
Does more whitespace or more tab need more interpreting time?
在PHP或Python(或其他)中,解释器逐行读取程序。
因此,如果我放了很多换行符或空行,代码是否需要更多的解释时间来执行? (因为它读取了我写的所有糟糕代码)。
白色space和制表符呢?
重要吗?
我认为更多的白色 space 和更多的制表符意味着更多的字节、更长的文件大小、更多的时间来读取文件。
这是否意味着解释器需要更多时间 read/process 来源?
根据作者 David Sklar 在 Learning PHP 5 中的说法:
You can put as many blank lines between statements as you want. The
PHP interpreter ignores them. The semicolon tells the interpreter that
one statement is over and another is about to begin. No whitespace at
all or lots and lots of whitespace between statements doesn't affect
the program's execution. (Whitespace is programmer-speak for
blank-looking characters such as space, tab, and newline.)
In practice, it's good style to put one statement on a line and to put
blank lines between statements only when it improves the readability
of your source code...
因此,请随意使用空白 space 和制表符来格式化您的 PHP 代码,使其清晰易读。
Python 与 PHP 不同,并且有关于如何使用空白 space 格式化代码的具体指南;参见 here。
在PHP或Python(或其他)中,解释器逐行读取程序。 因此,如果我放了很多换行符或空行,代码是否需要更多的解释时间来执行? (因为它读取了我写的所有糟糕代码)。
白色space和制表符呢? 重要吗?
我认为更多的白色 space 和更多的制表符意味着更多的字节、更长的文件大小、更多的时间来读取文件。
这是否意味着解释器需要更多时间 read/process 来源?
根据作者 David Sklar 在 Learning PHP 5 中的说法:
You can put as many blank lines between statements as you want. The PHP interpreter ignores them. The semicolon tells the interpreter that one statement is over and another is about to begin. No whitespace at all or lots and lots of whitespace between statements doesn't affect the program's execution. (Whitespace is programmer-speak for blank-looking characters such as space, tab, and newline.)
In practice, it's good style to put one statement on a line and to put blank lines between statements only when it improves the readability of your source code...
因此,请随意使用空白 space 和制表符来格式化您的 PHP 代码,使其清晰易读。
Python 与 PHP 不同,并且有关于如何使用空白 space 格式化代码的具体指南;参见 here。