Thank you to everyone who participated (Kirill, Raymond, Nick, Naoki). I've
decided there are too many caveats for this approach to be worthwhile and
I'm giving up on it.
Kind regards,
Tin
On Sat, Mar 24, 2018 at 3:18 PM Tin Tvrtković wrote:
> Hi Python-dev,
>
> I'm one of the core attrs contri
On Mar 25, 2018, at 8:08 AM, Tin Tvrtković wrote:
>
> That's reassuring, thanks.
I misspoke. The object size is the same but the underlying dictionary loses
key-sharing and doubles in size.
Raymond
___
Python-Dev mailing list
Python-Dev@python.org
>
> The dict can be replaced during __init__() and still get benefits of
> key-sharing. That benefit is lost only when the instance dict keys are
> modified downstream from __init__(). So, from a dict size point of view,
> your optimization is fine.
>
I think replacing __dict__ lose key-shari
On Sun, Mar 25, 2018 at 9:51 AM, Serhiy Storchaka wrote:
> 25.03.18 18:38, Tin Tvrtković пише:
>>
>> For example, for a simple class with 9 attributes:
> What are results for classes with 2 or 100 attributes? What are results in
> Python 3.5?
>
> I think you are playing on thin ice. Your results d
25.03.18 18:38, Tin Tvrtković пише:
For example, for a simple class with 9 attributes:
What are results for classes with 2 or 100 attributes? What are results
in Python 3.5?
I think you are playing on thin ice. Your results depend on
implementation details of the bytecode (in particularly o
On Sun, Mar 25, 2018 at 5:23 AM Nick Coghlan wrote:
> That depends on what you mean by "safe" :)
>
> It won't crash, but it will lose any existing entries that a metaclass,
> subclass, or __new__ method implementation might have added to the instance
> dictionary before calling the __init__ metho
That's reassuring, thanks.
On Sat, Mar 24, 2018 at 5:20 PM Raymond Hettinger <
raymond.hettin...@gmail.com> wrote:
> This should work. I've seen it done in other production tools without any
> ill effect.
>
> The dict can be replaced during __init__() and still get benefits of
> key-sharing. Tha
On 25 March 2018 at 00:18, Tin Tvrtković wrote:
> But is it safe to do on CPython?
>
That depends on what you mean by "safe" :)
It won't crash, but it will lose any existing entries that a metaclass,
subclass, or __new__ method implementation might have added to the instance
dictionary before c
> On Mar 24, 2018, at 7:18 AM, Tin Tvrtković wrote:
>
> it's faster to do this:
>
> self.__dict__ = {'a': a, 'b': b, 'c': c}
>
> 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,
On Sat, Mar 24, 2018 at 02:18:14PM +, Tin Tvrtković wrote:
> self.__dict__ = {'a': a, 'b': b, 'c': c}
>
> 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 t
2018-03-24 17:18 GMT+03:00 Tin Tvrtković :
>
> I've found that, if a class has more than one attribute, instead of
> creating an init like this:
>
> self.a = a
> self.b = b
> self.c = c
>
> it's faster to do this:
>
> self.__dict__ = {'a': a, 'b': b, 'c': c}
>
> i.e. to replace the
11 matches
Mail list logo