Triple Quoted Comments (Strings)
Triple Quoted Comments (Strings)
Do unassigned triple quoted strings consume memory or are they ignored by the interpreter?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Triple Quoted Comments (Strings)
They are ignored.
The way to check this kind of thing is to compile the Unix build. Write a small test script and issue
It will print the bytecode generated.
This is extremely informative.
The way to check this kind of thing is to compile the Unix build. Write a small test script and issue
Code: Select all
./micropython -v -v my_test.py
This is extremely informative.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Triple Quoted Comments (Strings)
Thanks Peter
-
- Posts: 59
- Joined: Mon Mar 29, 2021 1:36 am
- Location: Brisbane Australia
Re: Triple Quoted Comments (Strings)
The question appears somewhat confused though. All "Unassigned" strings are ignored in Python, not just MicroPython, so perhaps the question is intended to be asking specifically about docstrings? Using mpy-cross shows that docstrings are ignored in MicroPython, but obviously not in Python (unless you specify `python -OO`). Also, any reason triple-quoted strings are distinguised in the question? They are semantically equivalent to single quoted strings with regards to whether unassigned strings or docstrings are ignored or not.