Re: Differences performance Julia / PyPy on very similar codes

Antonio Cuni <[email protected]>
Newsgroups gmane.comp.python.pypy
Message-ID <CAHPg78y8+vWThUfS5dQ4JxKp5xj5QR-5C4h8ENY4N9xzNeQRgg@mail.gmail.com>
On Mon, Dec 21, 2020 at 11:19 PM PIERRE AUGIER <
[email protected]> 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

_______________________________________________
pypy-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.