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):
    print "Iter  x  y"
    for i in range(N):
        for j in range(thin):
        print i,x,y


From this blog post about the experiment.

  • 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
    Commented Jul 2, 2012 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... Commented Jul 2, 2012 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
    Commented Jul 2, 2012 at 20:24
  • 8
    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. Commented Jul 2, 2012 at 20:48
  • 1
    Stupid question... were you running the same version of python on both sides of the equation? I would expect on the same hardware, python3 will run the same code faster than python2 because range on python3 is an iterator and on python2, it creates the list which is less efficient (use xrange on python2)... see for example stackoverflow.com/questions/94935/…
    – Foon
    Commented Apr 3, 2013 at 1:07

2 Answers 2


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.


Python probably suffers from lack of cpu cache. I'm not sure how you can measure that easily though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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