We used Python 2 for the embedded application that we are currently prototyping on the Raspberry Pi. It was a bit slow but acceptable.
Now we have ported the application to Python 3. But for some reason, the application runs about 4 times slower than with Python 2! I expected Python 3 to be a bit slower, but nothing like that!
Our Linux distribution is based on Yocto 2.2 Morty, and we use the standard Python 3.5.2 recipe without any configuration. We also use a meta-raspberrypi layer for compatibility with raspberries.
I tried the time "pip3 --help" and got the following result:
$ time pip3 --help >/dev/null
real 0m22.686s
user 0m22.210s
sys 0m0.420s
Then I tried the same test on the same hardware (with the same SD card) using the latest Raspbian distribution:
$ time pip3 --help >/dev/null
real 0m6.874s
user 0m6.530s
sys 0m0.310s
$ time pip --help >/dev/null
real 0m4.329s
user 0m4.000s
sys 0m0.300s
Python 2 pip , Python 3, , pip3 3 Raspbian, Yocto!
, pyc - .
, Yocto , Raspbian?
Update:
Python Pip Raspbian vs Yocto , , Python:
Yocto 2.2 Morty:
sh-4.3# time python3 --version
Python 3.5.2
real 0m0.024s
user 0m0.010s
sys 0m0.000s
sh-4.3# time python3 -c "import asyncio"
real 0m3.439s
user 0m3.300s
sys 0m0.110s
Raspbian:
pi@raspberrypi:~$ time python3 --version
Python 3.4.2
real 0m0.020s
user 0m0.000s
sys 0m0.010s
pi@raspberrypi:~$ time python3 -c "import asyncio"
real 0m2.023s
user 0m1.850s
sys 0m0.160s
Python 3.5.2 Raspbian , (./configure; make; make install
). Python 3.5.2 :
pi@raspberrypi:~$ time python3.5 --version
Python 3.5.2
real 0m0.018s
user 0m0.000s
sys 0m0.010s
pi@raspberrypi:~$ time python3.5 -c "import asyncio"
real 0m2.689s
user 0m2.610s
sys 0m0.070s
, , Python 3.5 , 3.4, Yocto , Raspbian .
2:
Python 3.5.2 Yocto ( "./configure; make; make install" ) 20% Python:
root@la:/var/src/Python-3.5.2
real 0m2.914s
user 0m2.750s
sys 0m0.130s