When porting a program developed in Python to a CPU that is poorer than a PC like the Raspberry Pi, the slowness becomes noticeable.
I investigated the situation of Cython to see if it could be speeded up with as little effort as possible. (Scikit-learn and scikit-image use Cython to speed things up. Given that they can also be used on the Raspberry Pi, the Cython framework should work on the Raspberry Pi as well.)
I found a case of speeding up on Raspberry Pi using Cython. I'm investigating how to install Cython itself, sudo pip install cython Was found.
Speed of Python, at least for doing raw IO, is quiet disappointing. By using Cython (for the whole program), speeds becomes acceptable.
Identify functions that are bottlenecks and are worth rewriting -Write unit tests, -Based on Python, speed up by rewriting to pyx files. (Alternatively, write it in C / C ++ language and wrap it in Cython to speed it up.) -Confirm that the unit test is successful. Looks good.
With the C / C ++ source before using the NEON instruction C / C ++ source using NEON instruction It seems good to write and speed up with ARM.
Of course, it's important to do what you can optimize before Cython. It's easy to use the range () function in python2.7. Replaces the part replaced by xrange (). It is effective to use iterators and generators to process large lists without generating them.
[1]:Raspberry, running Python http://www.student.tue.nl/W/r.mientki/running_python.html
[2]:User’s Guide » Installation on Raspberry Pi Install Cython from sources (debian package are outdated): http://kivy.org/docs/installation/installation-rpi.html
Recommended Posts