[Python-Dev] A new dictionary implementation

Steven D'Aprano steve at pearwood.info
Mon Jan 30 00:30:14 CET 2012


Mark Shannon wrote:
> Antoine Pitrou wrote:
>> On 2012年1月29日 09:56:11 -0500
>> Benjamin Peterson <benjamin at python.org> wrote:
>>>>> 2012年1月29日 Mark Shannon <mark at hotpy.org>:
>>>> Hi,
>>>>>>>> Now that issue 13703 has been largely settled,
>>>> I want to propose my new dictionary implementation again.
>>>> It is a little more polished than before.
>>> If you're serious about changing the dictionary implementation, I
>>> think you should write a PEP. It should explain the new dicts
>>> advantages (and disadvantages?) and give comprehensive benchmark
>>> numbers. Something along the lines of
>>> http://www.python.org/dev/peps/pep-3128/ I should think.
>>>> "New dictionary implementation" is a misnomer here. Mark's patch merely
>> allows to share the keys array between several dictionaries. The lookup
>> algorithm remains exactly the same as far as I've read. It's actually
>> much less invasive than e.g. Martin's AVL trees-for-hash-collisions
>> proposal.
>>>> Antoine is right. It is a reorganisation of the dict, plus a couple of 
> changes to typeobject.c and object.c to ensure that instance 
> dictionaries do indeed share keys arrays.

I don't quite follow how that could work.
If I have this:
class C:
 pass
a = C()
b = C()
a.spam = 1
b.ham = 2
how can a.__dict__ and b.__dict__ share key arrays? I've tried reading the 
source, but I'm afraid I don't understand it well enough to make sense of it.
-- 
Steven


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /