diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2020-09-28 14:30:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-28 14:30:28 -0700 |
| commit | 785f2beed0c96945a770d05fef29251848ae3924 (patch) | |
| tree | 258535906fb835dac6bd7d6059f731ec3f820889 | |
| parent | ffeaef5d82a829fab9ce398f4d1a81b679af2d9b (diff) | |
| parent | 4d4dbbcafe4330d9dcd16535605d8990960972b1 (diff) | |
Merge pull request #3481 from caternuson/iss3480_docupdate
Add MP const info to Design Guide
| -rw-r--r-- | docs/design_guide.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 2d52e988b..cc2a3b296 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -485,6 +485,19 @@ struct.pack Use `struct.pack_into` instead of `struct.pack`. +Use of MicroPython ``const()`` +-------------------------------------------------------------------------------- +The MicroPython ``const()`` feature, as discussed in `this forum post +<https://forum.micropython.org/viewtopic.php?t=450>`_, and in `this issue thread +<https://github.com/micropython/micropython/issues/573>`_, provides some +optimizations that can be useful on smaller, memory constrained devices. However, +when using ``const()``, keep in mind these general guide lines: + +- Always use via an import, ex: ``from micropython import const`` +- Limit use to global (module level) variables only. +- If user will not need access to variable, prefix name with a leading + underscore, ex: ``_SOME_CONST``. + Sensor properties and units -------------------------------------------------------------------------------- |
