[pypy-dev] Differences performance Julia / PyPy on very similar codes

Antonio Cuni anto.cuni at gmail.com
Mon Dec 21 17:25:41 EST 2020


On Mon, Dec 21, 2020 at 11:19 PM PIERRE AUGIER <
pierre.augier at univ-grenoble-alpes.fr> wrote:


> class Point3D:
>     def __init__(self, x, y, z):
>         self.x = x
>         self.y = y
>         self.z = z
>
>     def norm_square(self):
>         return self.x**2 + self.y**2 + self.z**2
>

you could try to store x, y and z inside a list instead of 3 different
attributes: PyPy will use the specialized implementation which stores them
unboxed, which might help the subsequent code. You can even use @property
do expose them as .x .y and .z, since the JIT should happily remove the
abstraction away
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/pypy-dev/attachments/20201221/96fd09d2/attachment.html>


More information about the pypy-dev mailing list