Are comments stripped out of code?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Are comments stripped out of code?

Post by jgriessen » Thu Aug 09, 2018 11:56 pm

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: https://github.com/kanzure/culture_shock

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.
John Griessen blog.kitmatic.com

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Are comments stripped out of code?

Post by pythoncoder » Fri Aug 10, 2018 9:30 am

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.
Peter Hinch
Index to my micropython libraries.

User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: Are comments stripped out of code?

Post by jgriessen » Sat Aug 11, 2018 5:30 pm

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.
Last edited by jgriessen on Sun Aug 12, 2018 9:10 pm, edited 1 time in total.
John Griessen blog.kitmatic.com

efahl
Posts: 15
Joined: Sat Dec 23, 2017 2:02 pm

Re: Are comments stripped out of code?

Post by efahl » Sun Aug 12, 2018 3:17 pm

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.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Are comments stripped out of code?

Post by kevinkk525 » Sun Aug 12, 2018 7:26 pm

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?
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Post Reply