Skip to content

Commit 47f9b10

Browse files
committed
docs/speed_python: Generalize "Floating point" subsection.
Don't describe just single port's peculiarities, note aboute possible array of issues with floating-point.
1 parent 6c84f1e commit 47f9b10

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

docs/reference/speed_python.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ to read data into an existing buffer.
6767
Floating Point
6868
~~~~~~~~~~~~~~
6969

70-
For the most speed critical sections of code it is worth noting that performing
71-
any kind of floating point operation involves heap allocation. Where possible use
72-
integer operations and restrict the use of floating point to sections of the code
73-
where performance is not paramount.
70+
Some MicroPython ports allocate floating point numbers on heap. Some other ports
71+
may lack dedicated floating-point coprocessor, and perform arithmetic operations
72+
on them in "software" at considerably lower speed than on integers. Where
73+
performance is important, use integer operations and restrict the use of floating
74+
point to sections of the code where performance is not paramount. For example,
75+
capture ADC readings as integers values to an array in one quick go, and only then
76+
convert them to floating-point numbers for signal processing.
7477

7578
Arrays
7679
~~~~~~

0 commit comments

Comments
 (0)