Re: [pypy-dev] Safety of replacing the instance dict

2018-01-30 Thread Armin Rigo
Hi, On 30 January 2018 at 13:13, Antonio Cuni 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('instan

Re: [pypy-dev] Safety of replacing the instance dict

2018-01-30 Thread Antonio Cuni
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

Re: [pypy-dev] Safety of replacing the instance dict

2018-01-29 Thread Tin Tvrtković
Thanks a lot, Armin. If we go this way, it's easy to special case PyPy. On Mon, Jan 29, 2018 at 2:42 PM Armin Rigo wrote: > Hi, > > On 29 January 2018 at 11:22, Tin Tvrtković wrote: > > It's just that doing it this way is unconventional and a little scary. > Would > > we be violating a Python r

Re: [pypy-dev] Safety of replacing the instance dict

2018-01-29 Thread Armin Rigo
Hi, On 29 January 2018 at 11:22, Tin Tvrtković 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 P

[pypy-dev] Safety of replacing the instance dict

2018-01-29 Thread Tin Tvrtković
Hello, this question is not directly related to PyPy but to general Python semantics. I'm posting it here since I know there are very knowledgeable people here and honestly this is the friendliest list for questions like this. I'm working on optimizing __init__s that the attrs library generates.