The Magic of RPython
kirbyfan64.github.io
kirbyfan64.github.io
1) Huge compilation times, and compilation is non-incremental. Making even a small change to the source code causes it to be fully re-compiled, which on our project took 15-20 minutes (I can only imagine how painful this is on PyPy, which took me around 2 hours to build the time I tried it). I think the root cause of this is the static analysis and type inference, which needs to run again on the entire source code, and proved to be really slow on a huge code base. This was painful for development, so much time wasted on waiting on the compiler.
2) My experience with error messages was not as positive as the OP's. Sometimes, I'd make a type error in the code and get a cryptic error message, and have to guess by myself what caused it. Perhaps things have improved since then (I see some new details in the errors in the article that weren't there when I used RPython).
I would have much preferred type inference with robust error messages, or frankly, even Java style verbosity to what I got out of RPython. It's a shame, because it's obviously a very impressive system.
For instance, I have the following two functions:
def atLeast2(a,b,num):
return sum(x==y for x,y in itertools.zip_longest(reversed(bin(a).partition('b')[-1]), reversed(bin(b).partition('b')[-1]), fillvalue='0')) >= num
def atLeast4(a,b,num):
count = 0
while a > 0 or b > 0:
x = a % 2
y = b % 2
if x == y:
count += 1
if count >= num:
return True
a //= 2
b //= 2
return count >= num
In Python, atLeast2 is ~2.7x faster than atLeast4. In Pypy, atLeast2 is 1.9x slower than atLeast4.(The ordering is roughly, using relative numbers (lower = faster), and checking for at least 96 bits in common out of 128 for random inputs:
1.0 pypyatLeast
3.2515636711379905 pypyatLeast4
3.5864477527073473 pypyatLeast3
4.430998164947921 pythonatLeast
5.903265617327027 pythonatLeast2
6.306511850301104 pypyatLeast2
15.832777648548758 pythonatLeast4
15.870273448605621 pythonatLeast3
Note that atLeast2 is slower in PyPy than Python! def atLeast(a, b, num):
count = 0
for x, y in zip(bin(a).partition('b')[-1], bin(b).partition('b')[-1]):
if x == y:
count += 1
if count >= num:
return True
return False
def atLeast3(a,b,num):
count = 0
while a > 0 or b > 0:
x = a % 2
y = b % 2
if x == y:
count += 1
a //= 2
b //= 2
return count >= num
)Edit: it appears to be covered by https://bitbucket.org/pypy/pypy/issues/2100/sum-map-foo-is-m...