Page 1 of 1

Are comments stripped out of code?

Posted: Thu Aug 09, 2018 11:56 pm
by jgriessen
I'm using a new platform based on STM32F401CE with 512KB Flash/96KB RAM similar to the G30TH, but targeted to using flat flex cables to connect modules instead of 0.1 inch pitch .025 inch square pins and headers. Flex cables make fitting something in an enclosure so much easier.

We may be running out of code space soon and I wondered if comments are already stripped out during compile, or if that needs an extra step?

Here's the project:

The platform can be for sale in a while for investigating high voltage D2A, using flat flex cables, other micropython applications.
Flat flex cables are not easy to get generically, so I'm going to be selling them to use to make modules connect at easy prices like 35 cents each for short cables and connectors for 20 conductors. They'll be for sale in ten packs that ship postal tracked for $3. So $13.50 will get you ten connections between prototype boards that can be used 500 times without much degradation, and even work fairly well in humidity.

Re: Are comments stripped out of code?

Posted: Fri Aug 10, 2018 9:30 am
by pythoncoder
Compilation converts Python source to bytecode which has no comments. When you say you're running out of code space, what exactly do you mean? If you mean that your code is too big to compile on the target, consider using the cross-compiler or frozen bytecode.

Re: Are comments stripped out of code?

Posted: Sat Aug 11, 2018 5:30 pm
by jgriessen
Thanks, I'm not out of space yet, and it's good to know that the comments can flow freely as I improve my code.
I am just loading files to /flash, so they get compiled on the target, but I know how to cross compile instead when I need to.
I'm going to lookup a command to show available flash.

Re: Are comments stripped out of code?

Posted: Sun Aug 12, 2018 3:17 pm
by efahl
What about docstrings? I'm too lazy to look at the microPython docs, but I know that with cPython the -OO command line option strips out docstrings, which otherwise eat up space in the bytecode, just wondering of uPy has similar options.

Re: Are comments stripped out of code?

Posted: Sun Aug 12, 2018 7:26 pm
by kevinkk525
So you are too lazy to look at the micropython docs (or at least google it) but other people should not be too lazy to reply to your question?