Hi, On 30 January 2018 at 13:13, Antonio Cuni <anto.c...@gmail.com> wrote: > 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 a no-op, which takes time to execute but indeed doesn't seem to disable the optimization. However I don't see the point. You may as well write it like that: def __init__(self, x, y, z): d = self.__dict__ d['x'] = x d['y'] = y d['z'] = z It is a bit slower than "self.x = x; self.y = y; self.z = z" in PyPy but doesn't throw away the optimization. On CPython it is probably faster. Armin _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev