Tell me more ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I've been benchmarking the Pi on some of my simulation codes, relative to a couple of laptops I have. My codes tend to be floating point intensive, so I've been using Raspbian (which turns out to be much faster) due to its hard-float support. I have the same simple code in several different languages. Obviously python code is slower than C code whatever platform I use, but on the Pi it appears to be relatively more slow, by a factor of around 3. Does anyone know why the python interpreter is likely to be relatively slow on the Pi, and is this something that is likely to be fixed?

Here is the test:

import random,math

def gibbs(N=50000,thin=1000):
    x=0
    y=0
    print "Iter  x  y"
    for i in range(N):
        for j in range(thin):
            x=random.gammavariate(3,1.0/(y*y+4))
            y=random.gauss(1.0/(x+1),1.0/math.sqrt(2*x+2))
        print i,x,y

gibbs()

From this blog post about the experiment.

share|improve this question
2  
Self promotion is fine (within reason) but all your blog link really added to the question was the code, so I've moved it here instead. – Jivings Jul 2 '12 at 20:05
2  
Um, it also contained details and timings and other potentially useful background which substantiated the claim that python is slower relative to C on the Pi than on Intel based linux machines, which was kind of the point of the question... – darrenjw Jul 2 '12 at 20:18
2  
I read the whole post, I don't think it contributed information incredibly relevant to the question. And asking everyone to read a page of information before they can answer your question is not going to get you a lot of answers. Programmers are by definition, lazy. We need all the information in easy to digest chunks :) – Jivings Jul 2 '12 at 20:24
7  
That's a judgement call that I'm fine with, as I'm an easy-going kind of guy... But I am a bit concerned that this zealous over-editing of almost every question posted on this site is likely to deter people from participating. I know it's done with the best of intentions, but you know what they say about the road to Hell... I really think it's something that all of you very active question editors should take some time to think and chat about. It would be a real shame if this site didn't take off because of the actions of a few well-intentioned but misguided individuals. – darrenjw Jul 2 '12 at 20:48
You bring up interesting points, please come and discuss this issue in chat if you have the time. – Jivings Jul 2 '12 at 21:04
show 4 more comments

1 Answer

up vote 2 down vote accepted

I would guess that the Python interpreter is simply not optimized for ARM. Python might have been optimized for the other platforms. In my experience, this is true for software like OpenSSH, so I assume it's similar for Python.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.