Is a comment increase size of your programme ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Is a comment increase size of your programme ?

If we use a #comment and a docstring do the both have same effects on the programme size in python3?

20th Mar 2019, 2:41 AM
Krishan
Krishan - avatar
1 Answer
+ 4
Comments do increase your script size, but whatever intermediate files which are generated by your script does not involve comments, since comments are ignored by the interpreter (or compiler, for compiled languages). As such, the size of the resulting executable is unaffected by comments. Docstrings, on the other hand, needs to be accessed by the interpreter (as you can retrieve them using special variables), and hence are acknowledged by the interpreter. This means that the resulting binaries when you use docstrings instead of comments might actually take up more space, but the difference should be negligible.
20th Mar 2019, 2:56 AM
Fermi
Fermi - avatar