<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>Hi Python-dev,<br><br></div>I'm one of the core attrs contributors, and I'm contemplating applying an optimization to our generated __init__s. Before someone warns me python-dev is for the development of the language itself, there are two reasons I'm posting this here:<br><br></div>1) it's a very low level question that I'd really like the input of the core devs on, and<br></div>2) maybe this will find its way into dataclasses if it works out.<br><br></div>I've found that, if a class has more than one attribute, instead of creating an init like this:<br><br></div>    self.a = a<br></div>    self.b = b<br></div>    self.c = c<br><br></div>it's faster to do this:<br><br></div>    self.__dict__ = {'a': a, 'b': b, 'c': c}<br><br></div>i.e. to replace the instance dictionary altogether. On PyPy, their core devs inform me this is a bad idea because the instance dictionary is special there, so we won't be doing this on PyPy. <br><br>But is it safe to do on CPython?<br><br></div>To make the question simpler, disregard the possibility of custom setters on the attributes.<br><br></div>Thanks in advance!<br></div>