docs/speed_python: Generalize "Floating point" subsection.

Don't describe just single port's peculiarities, note aboute possible
array of issues with floating-point.
pull/1888/merge
Paul Sokolovsky 2016-04-15 17:43:03 +03:00
rodzic 6c84f1e03a
commit 47f9b10b30
1 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -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
~~~~~~