Skip to content

Commit 785f2be

Browse files
authored
Merge pull request #3481 from caternuson/iss3480_docupdate
Add MP const info to Design Guide
2 parents ffeaef5 + 4d4dbbc commit 785f2be

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/design_guide.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,19 @@ struct.pack
485485

486486
Use `struct.pack_into` instead of `struct.pack`.
487487

488+
Use of MicroPython ``const()``
489+
--------------------------------------------------------------------------------
490+
The MicroPython ``const()`` feature, as discussed in `this forum post
491+
<https://forum.micropython.org/viewtopic.php?t=450>`_, and in `this issue thread
492+
<https://github.com/micropython/micropython/issues/573>`_, provides some
493+
optimizations that can be useful on smaller, memory constrained devices. However,
494+
when using ``const()``, keep in mind these general guide lines:
495+
496+
- Always use via an import, ex: ``from micropython import const``
497+
- Limit use to global (module level) variables only.
498+
- If user will not need access to variable, prefix name with a leading
499+
underscore, ex: ``_SOME_CONST``.
500+
488501
Sensor properties and units
489502
--------------------------------------------------------------------------------
490503

0 commit comments

Comments
 (0)