Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

FWIW PyPy is signfificantly faster than CPython in a lot of tasks.


view as:

PyPy doesn't support a lot of CPython's reflection and introspection.

to see the problem with Python, take this loop as an example:

    x = 0
    for i in range(0,1000):
        x = x + i
There is no way, looking only at this part of the code to know if the `+` operator does the same operation every time it is executed.

Wouldn't that require some code to redefine `int.__add__` or `int.__radd__` between iterations of the loop? Which I would file under "bizarre shit that shouldn't normally happen." Before the loop starts, you'd have to override `int.__add__` to modify itself every time it's called, or something crazy.

If we're talking about custom classes and not ints, maybe it's a bigger problem. But if PyPy doesn't allow the required introspection to make this work, how does it run anything at all?


Legal | privacy