2

OS: Ubuntu 14.04

CPU: i7

  1. I Installed PyPy+Numpy:

    sudo add-apt-repository ppa:pypy/ppa
    sudo apt-get update
    sudo apt-get install pypy pypy-dev
    pip install git+https://bitbucket.org/pypy/numpy.git
    
  2. Ran following code with python and pypy:

    import numpy as np
    import time
    
    start = time.clock()
    
    for i in range(5):
        vv = np.random.rand(9000000).astype(np.float32)
        m = np.mean(vv)
    
    print 'Done in %.3f s %s ' % (time.clock()-start,m)
    

    And got the following timings:

    $python testSpeed_.py
    Done in 1.908 s 0.499997
    
    $pypy testSpeed_.py
    Done in 4.599 s 0.499952167273 
    

i.e. no performance improvement. Should I have gotten a performance boost?

Alec
  • 8,529
  • 8
  • 37
  • 63
pvstrln
  • 169
  • 3
  • 10
  • 9
    I don't see why pypy would help you with this kind of stuff - numpy is really a wrapper for C functions. – Ami Tavory Jul 09 '15 at 16:09
  • Relevant: http://stackoverflow.com/q/18946662/1461210 – ali_m Jul 09 '15 at 16:27
  • you will see improvements with PyPy if you try to do anything in Python code (e.g. iterate over numpy arrays), however vectorized operations will be at best as fast (but indeed sometimes even slower), since then you're just calling optimized C and there is not that much to be done. – fijal Jul 11 '15 at 17:29

1 Answers1

1

Per documentation of PyPy here, numpy under PyPy is slow:

At the moment of writing (October 2017) the main drawback of numpy is that cpyext is infamously slow

Anastasios Andronidis
  • 6,310
  • 4
  • 30
  • 53