This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients Mark.Shannon, benjamin.peterson, methane, rhettinger, serhiy.storchaka
Date 2016-10-23.02:25:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAEfz+Tya7COaYGobYteNsBstbOw0N4Yv8jJXwP1erR__Zy=05w@mail.gmail.com>
In-reply-to <1477163617.95.0.961480932723.issue28509@psf.upfronthosting.co.za>
Content
> 0 (128, 60)
> 1 (128, 60)
> 2 (128, 60)
> 3 (128, 60)
> 4 (128, 60)
> 5 (128, 60)

Minimum dict keysize is 8, and it's capacity is 5.

> 6 (196, 196)

Dict is resized. And since __dict__.update() caused the resizing,
both are normal (combined) dict.

> 7 (196, 196)
> 8 (196, 344)

dict.update() cause faster increasing keysize.

Adding to dict cause resizing when number of items reaches 2/3 of keysize.
On the other hand, dict.update() targets 1/2 of keysize is filled.

In this case, keysize is 16 and 16 * 2 // 3 = 10. Since 8 < 10, adding
item to key
doesn't increase it's size. Since 8 >= (16 / 2), dict.update() creates
dict having keysize == 32.

(note: My patch in http://bugs.python.org/issue28147 changes >= to >.
So keysize == 16 when
number of items == 8).

But, while checking this, I found another bug in dict_merge.

        /* Do one big resize at the start, rather than
         * incrementally resizing as we insert new items.  Expect
         * that there will be no (or few) overlapping keys.
         */
        if (mp->ma_keys->dk_usable * 3 < other->ma_used * 2)
            if (dictresize(mp, (mp->ma_used + other->ma_used)*2) != 0)
               return -1;

dk_usable means "how many new items can be inserted without resizing".
So this if statement should be:

        if (mp->ma_keys->dk_usable < other->ma_used)
History
Date User Action Args
2016-10-23 02:25:55methanesetrecipients: + methane, rhettinger, benjamin.peterson, Mark.Shannon, serhiy.storchaka
2016-10-23 02:25:55methanelinkissue28509 messages
2016-10-23 02:25:53methanecreate