To test the claims that Pypy JIT is significantly faster I wrote a simple code that repeatedly adds two arrays of size 1200x1200. My code is as follows
import numpy as np
import random
a=np.zeros((1200, 1200), dtype=np.float32)
b=np.zeros((1200, 1200), dtype=np.float32)
import timeit
#Start timer
start=timeit.default_timer()
#Initialize the arrays
for j in range(1200):
for k in range(1200):
a[j][k]=random.random()
b[j][k]=random.random()
#Repeatedly add the arrays
for j in range(10):
a=np.add(a,b)
#Stop timer and display the results
stop=timeit.default_timer()
print stop-start
With normal python the time taken for execution is about 1.2 - 1.5sec. However with Pypy it it more than 15sec? Also in the above case I have added the arrays only 10 times. If I increase this value to 1000, my computer stops responding. I found that this was because almost the entire RAM was consumed while using pypy. Am I doing something wrong? Or is the issue something else?