From 8e4f08a109980e76df43cd95f8bca96422ae89ce Mon Sep 17 00:00:00 2001 From: caternuson Date: Mon, 28 Sep 2020 13:15:43 -0700 Subject: [PATCH 1/2] add MP const info to Design Guide --- docs/design_guide.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 6f87ecf798..9ce8dc9636 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -448,6 +448,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 +`_, and in `this issue thread +`_, 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 -------------------------------------------------------------------------------- From 4d4dbbcafe4330d9dcd16535605d8990960972b1 Mon Sep 17 00:00:00 2001 From: caternuson Date: Mon, 28 Sep 2020 13:28:38 -0700 Subject: [PATCH 2/2] RST tweak --- docs/design_guide.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 9ce8dc9636..a00caf1d69 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -448,18 +448,18 @@ struct.pack Use `struct.pack_into` instead of `struct.pack`. -Use of MicroPython `const()` +Use of MicroPython ``const()`` -------------------------------------------------------------------------------- -The MicroPython `const()` feature, as discussed in `this forum post +The MicroPython ``const()`` feature, as discussed in `this forum post `_, and in `this issue thread `_, provides some optimizations that can be useful on smaller, memory constrained devices. However, -when using `const()`, keep in mind these general guide lines: +when using ``const()``, keep in mind these general guide lines: -- Always use via an import, ex: `from micropython import const` +- 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`. + underscore, ex: ``_SOME_CONST``. Sensor properties and units --------------------------------------------------------------------------------