From 47f9b10b303abc9fd1cf637f2b62e97ab118cac0 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 15 Apr 2016 17:43:03 +0300 Subject: [PATCH] docs/speed_python: Generalize "Floating point" subsection. Don't describe just single port's peculiarities, note aboute possible array of issues with floating-point. --- docs/reference/speed_python.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/reference/speed_python.rst b/docs/reference/speed_python.rst index 31b5aeadda..86884a1577 100644 --- a/docs/reference/speed_python.rst +++ b/docs/reference/speed_python.rst @@ -67,10 +67,13 @@ to read data into an existing buffer. Floating Point ~~~~~~~~~~~~~~ -For the most speed critical sections of code it is worth noting that performing -any kind of floating point operation involves heap allocation. Where possible use -integer operations and restrict the use of floating point to sections of the code -where performance is not paramount. +Some MicroPython ports allocate floating point numbers on heap. Some other ports +may lack dedicated floating-point coprocessor, and perform arithmetic operations +on them in "software" at considerably lower speed than on integers. Where +performance is important, use integer operations and restrict the use of floating +point to sections of the code where performance is not paramount. For example, +capture ADC readings as integers values to an array in one quick go, and only then +convert them to floating-point numbers for signal processing. Arrays ~~~~~~