<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-03-24 17:18 GMT+03:00 Tin Tvrtković <span dir="ltr"><<a href="mailto:tinchester@gmail.com" target="_blank">tinchester@gmail.com</a>></span>:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><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></div></div></div></blockquote><div><br></div><div>But why you need to replace it? When you can just update it:</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="monospace, monospace">class C:</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">    def __init__(self, a, b, c):</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">        self.__dict__.update({'a': a, 'b': b, 'c': c})</font></div><div><br></div></div></div></blockquote>I'm certainly not a developer. Just out of curiosity.<div><br></div><div>With kind regards,</div><div>-gdg<br><div class="gmail_extra"><br></div></div></div>