-
- Posts: 5
- Joined: Tue Apr 29, 2014 7:30 am
Python is barely usable on Raspbian
Hi,
I don't know if you guys have the same issue but it seems that Python executables are really really slow on my pi. For example, just running "pip" with no args takes about 5 seconds of 90% cpu just to print the help message.
Does anybody else have the same issue? And what exactly is causing it?
I don't know if you guys have the same issue but it seems that Python executables are really really slow on my pi. For example, just running "pip" with no args takes about 5 seconds of 90% cpu just to print the help message.
Does anybody else have the same issue? And what exactly is causing it?
Re: Python is barely usable on Raspbian
Python is perfectly usable on the Pi.
Perhaps pip is a bad choice of benchmark.
Perhaps pip is a bad choice of benchmark.
-
- Posts: 5
- Joined: Tue Apr 29, 2014 7:30 am
Re: Python is barely usable on Raspbian
Flexget is also extremely slow on my machine. It takes about 20 seconds to print the help message.
how is the cpu usage on your machine? Do you know what could be causing the bad performance on mine?
how is the cpu usage on your machine? Do you know what could be causing the bad performance on mine?
- DougieLawson
- Posts: 40532
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Python is barely usable on Raspbian
What else is running? It may be worth killing that bitcoin miner when you want to run python 
Take a look with the top command.

Take a look with the top command.
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: Python is barely usable on Raspbian
I am using python heavily on my raspberries. I have not seen that they aer slow.
I have not used pip though, so can't comment that. But it seems to be a package managing thing, so does it really matter if it is slow?
I think the main thing is that python scipts work fast? Or do you see slowness in real python?
I have not used pip though, so can't comment that. But it seems to be a package managing thing, so does it really matter if it is slow?
I think the main thing is that python scipts work fast? Or do you see slowness in real python?
Re: Python is barely usable on Raspbian
To the best of my knowledge I have never used pip or flexget.
I know pip is some sort of Python package management system. It needs to access the internet to generate an index of source distribution archives. That can be time consuming on any machine. I'd think especially so the first time through.
I have never heard of flexget but it sounds like a similar tool and may have similar problems.
I know pip is some sort of Python package management system. It needs to access the internet to generate an index of source distribution archives. That can be time consuming on any machine. I'd think especially so the first time through.
I have never heard of flexget but it sounds like a similar tool and may have similar problems.
-
- Posts: 5
- Joined: Tue Apr 29, 2014 7:30 am
Re: Python is barely usable on Raspbian
I was keeping an eye on "top". Like I said, "pip" and "flexget" were using 90+% of the cpu.
I'm not really worried about "pip". My main issue is "flexget"'s performance. Does anybody know of a python benchmarking tool or something that I can use to confirm the performance issue?
I'm not really worried about "pip". My main issue is "flexget"'s performance. Does anybody know of a python benchmarking tool or something that I can use to confirm the performance issue?
-
- Posts: 5
- Joined: Tue Apr 29, 2014 7:30 am
Re: Python is barely usable on Raspbian
it's taking pip over 5 seconds just to print the help message. Not index or download packages. All the while using 90+% of the cpu. I don't think that is normal.
Re: Python is barely usable on Raspbian
What performance do you see on other Python applications? Sounds to me like this might be Pip/Flexget specific. Do they both access the network whilst running (even with just help)?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Re: Python is barely usable on Raspbian
quick test from my raspberry: Build file test.py:
$ python test.py
0.595
Code: Select all
import time
x = 0
def doit1(i):
global x
x = x + i
list = range(100000)
t = time.time()
for i in list:
doit1(i)
print "%.3f" % (time.time()-t)
$ python test.py
0.595
- pluggy
- Posts: 3635
- Joined: Thu May 31, 2012 3:52 pm
- Location: Barnoldswick, Lancashire,UK
- Contact: Website
Re: Python is barely usable on Raspbian
The Pi has a puny CPU, if you're used to a late model fast X86 processor, the Pi is a couple of orders of magnitude slower.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......
I must not tread on too many sacred cows......
-
- Posts: 5
- Joined: Tue Apr 29, 2014 7:30 am
Re: Python is barely usable on Raspbian
shuckle, I got a 10 times average of 0.885
Re: Python is barely usable on Raspbian
Sorry, I run it in my 1100MHz overclocked raspi.
Three runs in base 700MHz raspberry gives:
$ python koe.py
0.895
$ python koe.py
1.029
$ python koe.py
1.101
I have a little other load there also, so this matches pretty well with yoru results.
As pluggy said...this is what raspberry CPU can do. It can not break records. But it works well for me.
Three runs in base 700MHz raspberry gives:
$ python koe.py
0.895
$ python koe.py
1.029
$ python koe.py
1.101
I have a little other load there also, so this matches pretty well with yoru results.
As pluggy said...this is what raspberry CPU can do. It can not break records. But it works well for me.
Re: Python is barely usable on Raspbian
¿1 second to just count to 100.000? That was acceptable at 1990s but not today imo.
I've tried to use it for a proyect but I just can't do it with this times. Imo Raspberry is not even barely usable in raspberry.. I hope it was a configuration mistake or something similar but this are my tests for the same code in go (i.e.):
That's crazy :/
Am I doing something wrong? There are some kind of configuration of python that it haven't for default?
I've tried to use it for a proyect but I just can't do it with this times. Imo Raspberry is not even barely usable in raspberry.. I hope it was a configuration mistake or something similar but this are my tests for the same code in go (i.e.):
Code: Select all
pi@raspberrypi ~ $ python3.2 count.py
0.972
pi@raspberrypi ~ $ go run count.go
0.0014190000000000001
Am I doing something wrong? There are some kind of configuration of python that it haven't for default?
Re: Python is barely usable on Raspbian
ianholing wrote:¿1 second to just count to 100.000? That was acceptable at 1990s but not today imo.
I've tried to use it for a proyect but I just can't do it with this times. Imo Raspberry is not even barely usable in raspberry.. I hope it was a configuration mistake or something similar but this are my tests for the same code in go (i.e.):
That's crazy :/Code: Select all
pi@raspberrypi ~ $ python3.2 count.py 0.972 pi@raspberrypi ~ $ go run count.go 0.0014190000000000001
Am I doing something wrong? There are some kind of configuration of python that it haven't for default?
??? You seem to be under the mistaken belief that the Pi is as fast as a modern desktop! If it was, it would cost the same as a modern desktop.
It has a 700Mhz ARv6 processor, equivalent to about a 300-400Mhz Pentium2.
If Python is too slow (and it will be for some applications), use a compiled language which will be much faster, like C or C++.
Or write better code.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
-
- Posts: 319
- Joined: Sun Aug 19, 2012 5:56 am
- Location: Finland
Re: Python is barely usable on Raspbian
You are comparing an interpreted language to a compiled language. If you want speed, use a compiled language like Go or C. Python is designed with other priorities. If you don't need or appreciate what Python has to offer and/or need the speed of execution, it is good that there are plenty of options to choose from.ianholing wrote:¿1 second to just count to 100.000? That was acceptable at 1990s but not today imo.
I've tried to use it for a proyect but I just can't do it with this times. Imo Raspberry is not even barely usable in raspberry.. I hope it was a configuration mistake or something similar but this are my tests for the same code in go (i.e.):
That's crazy :/Code: Select all
pi@raspberrypi ~ $ python3.2 count.py 0.972 pi@raspberrypi ~ $ go run count.go 0.0014190000000000001
Am I doing something wrong? There are some kind of configuration of python that it haven't for default?
Last edited by Sleep Mode zZ on Thu Jan 15, 2015 2:38 pm, edited 1 time in total.
- Richard-TX
- Posts: 1549
- Joined: Tue May 28, 2013 3:24 pm
- Location: North Texas
Re: Python is barely usable on Raspbian
Just to give you an idea of the speed of a Raspberry vs an older desktop vs a modern desktop, here are the compile times of the same software package on different hardware.
Raspberry pi ~1 hour 45 minutes
Beaglebone -~ 50 minutes
Dell 690 (3 Ghz quad core) ~6 minutes
new computer ~ 3 minutes.
Raspberry pi ~1 hour 45 minutes
Beaglebone -~ 50 minutes
Dell 690 (3 Ghz quad core) ~6 minutes
new computer ~ 3 minutes.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip
Re: Python is barely usable on Raspbian
I wonder how much of that time is I/O? Someone should do the compile test using an SD card as the input/output media.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Re: Python is barely usable on Raspbian
That is so true. IO is often a perf killer that is overlooked:jamesh wrote:I wonder how much of that time is I/O? Someone should do the compile test using an SD card as the input/output media.
as a comparison (latest greatest cruncher & NFS server), building a simulation database for an ASIC that takes 1.2 GIG of disk space will takes 20 minutes when on a NFS server, versus 5 minutes when built on the local disk of the same cruncher.
Could be interesting also to perform the python tests on a USB hard drive connected to the PI vs the SD card.
Ben
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191
Re: Python is barely usable on Raspbian
Any news on this?
It's killing me how slow pip is just to show the help message, or doing a simple freeze.
It's killing me how slow pip is just to show the help message, or doing a simple freeze.
Re: Python is barely usable on Raspbian
That's just how it works. There's nothing you can do about it.
There are 10 types of people: those who understand binary and those who don't.
- mahjongg
- Forum Moderator
- Posts: 13567
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Python is barely usable on Raspbian
Tried the Python code above on my modern PC (after modifying the print command for Python 3.4) so this:
and it came out as 0,03, which is just about 20 times faster than the PI's 0.595 second.
seems reasonable to me, python isn't that fast! and a PI being twenty times slower than a modern PC seems a good estimate of the PI's speed.
That code scored 0.15 sec on my PC.
By the way, which PI are you using?
Code: Select all
import time
x = 0
def doit1(i):
global x
x = x + i
list = range(100000)
t = time.time()
for i in list:
doit1(i)
print ("%.3f" % (time.time()-t))
seems reasonable to me, python isn't that fast! and a PI being twenty times slower than a modern PC seems a good estimate of the PI's speed.
In defense of python. the above code is not simply counting to 100.000, this code does it better, but modified for 1000.000 as otherwise it was too fast!¿1 second to just count to 100.000? That was acceptable at 1990s but not today imo.
Code: Select all
import time
list = 1000000
t = time.time()
i = 1
while i < list:
i = i+1
print ("%.3f" % (time.time()-t))
By the way, which PI are you using?
Re: Python is barely usable on Raspbian
I have raised this issue with pip as it seems this issue is not unique to the Raspberry Pi.
https://github.com/pypa/pip/issues/3360
https://github.com/pypa/pip/issues/3360
Re: Python is barely usable on Raspbian
My Pi2 executes the python3 script in 0.246 seconds.
About 17 times slower than my PC which cost 45 times as much, and uses about 150 times as much electricity. The Pi2 is a bargain!
About 17 times slower than my PC which cost 45 times as much, and uses about 150 times as much electricity. The Pi2 is a bargain!
Pi4 8GB and Pi4 4GB running Raspberry Pi OS 64-bit
Re: Python is barely usable on Raspbian
Could you try to runjahboater wrote:My Pi2 executes the python3 script in 0.246 seconds.
About 17 times slower than my PC which cost 45 times as much, and uses about 150 times as much electricity. The Pi2 is a bargain!
Code: Select all
$ time pip -h
Code: Select all
$ time pip3 -h