[Tutor] commenting code well

Rob Andrews rob@jam.rr.com
Sun, 1 Jul 2001 08:21:43 -0500


-----Original Message-----
From: Kojo Idrissa [mailto:kojo@hal-pc.org]
Sent: Sunday, July 01, 2001 1:16 AM
To: Rob Andrews
Subject: Re: [Tutor] commenting code well


> Now, I have a question for the group, related to my verbose commenting
style.  At what point do lines of commentary begin  > to impact program
performance, if at all?  If I remember correctly, in C, the comment lines
are completly ignored by the
> compiler, so there's no problem.  But if I have a short program and the
comments are longer than the program, does that
> become a problem in some languages?  I'm working on a "Personal Version
Calculator" right now that "works" in 4 lines and
> in the end may be less than 100 lines long (depends on how much other
functionality I add).  My 'comments' are, like, 3
> times the length of the program at this point.  When doe that become a
problem if ever?

I could be quite wrong on this, at least in some technical details, but I'll
reveal my ignorance if it turns out to be such. If you add 300 pages of
comments to your 20-line obfuscated "hello world" script, it might take a
bit of time for all this to be read when the Python interpreter first reads
your obfuscatedhi.py file. But when it's done, it will create
obfuscatedhi.pyc, which is the interpreted version. This file contains only
bytecode, which is comment-free. As long as this .pyc file is more recent
than your .py file of the same name, this is the one which will be executed
(after the first time you run obfuscatedhi.py).

So if extremely heavy comments slow down your program, it should only do it
the first time.

I could be wrong,
Rob

Useless Python:
Aw, heck, we love you!
http://www.lowerstandard.com/python/