sidenote: if you do the following, you can replace the __dict__ without
incurring into performance penalties (Armin, please correct me if I'm
wrong):

import __pypy__
def __init__(self):
    self.__dict__ = __pypy__.newdict('instance')

this is not directly useful for your use case (because newdict() always
return an empty dict), but it might be useful to know in general

On Mon, Jan 29, 2018 at 1:41 PM, Armin Rigo <armin.r...@gmail.com> wrote:

> Hi,
>
> On 29 January 2018 at 11:22, Tin Tvrtković <tinches...@gmail.com> wrote:
> > It's just that doing it this way is unconventional and a little scary.
> Would
> > we be violating a Python rule somewhere and making stuff blow up later
> if we
> > went this way?
>
> No, it's semantically fine.  But it comes with a heavy penalty on
> PyPy.  I guess you don't see it because you measured something tiny,
> like creating the instance and then throwing it away---the JIT
> optimizes that to nothing at all in both cases.  Not only is the
> creation time larger, but attribute access is slower, and the memory
> usage is larger.
>
>
> A bientôt,
>
> Armin.
> _______________________________________________
> pypy-dev mailing list
> pypy-dev@python.org
> https://mail.python.org/mailman/listinfo/pypy-dev
>
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to