To test the claims that Pypy JIT is significantly faster, I wrote simple code that repeatedly adds two 1200x1200 sized arrays. 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=timeit.default_timer()
for j in range(1200):
for k in range(1200):
a[j][k]=random.random()
b[j][k]=random.random()
for j in range(10):
a=np.add(a,b)
stop=timeit.default_timer()
print stop-start
With a regular python, the time spent on execution is about 1.2 - 1.5 seconds. However, with Pypy, is this more than 15 seconds? Also in the above case, I added arrays only 10 times. If I increase this value to 1000, my computer will stop responding. I found that this is due to the fact that almost all RAM was consumed when using pypy. Am I doing something wrong? Or is the problem different?
source
share