Author yselivanov
Recipients haypo, inada.naoki, rhettinger, serhiy.storchaka, yselivanov
Date 2017-08-11.14:48:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1502462881.73.0.0978090415954.issue31179@psf.upfronthosting.co.za>
In-reply-to
Content
> I like idea.
> One worrying point is how to deal with dirty dict.
> How about do it only when ma_used == keys->dk_nentries?

I've added this check.  See the updated PR.

> The PR changes the behavior. Currently the effect of copying is compacting the dict.

The check that INADA suggested enables compacting on copy, if it is needed.

> The PR adds over 50 lines of code for optimising not very often used feature.

I started to look into the problem because I need this for my upcoming PEP, so please don't dismiss this idea right away.

I also think that copying a dict isn't a "not very often used feature", it depends on your frame of references.  In some applications you do copy dict a lot.  50 lines of code speeding up one of the core methods 5.5x is a fair price to pay.

> There are two obvious ways of copying, dict(d) and d.copy()

That can also be easily optimized, btw.  I'll see if I can do that without impacting the performance of creating new dicts.

> The PR duplicates the low-level code, that increases maintainability cost.

FWIW, the PR doesn't duplicate any of the code.  It provides a new implementation that is more efficient than the old approach.
History
Date User Action Args
2017-08-11 14:48:01yselivanovsetrecipients: + yselivanov, rhettinger, haypo, inada.naoki, serhiy.storchaka
2017-08-11 14:48:01yselivanovsetmessageid: <1502462881.73.0.0978090415954.issue31179@psf.upfronthosting.co.za>
2017-08-11 14:48:01yselivanovlinkissue31179 messages
2017-08-11 14:48:00yselivanovcreate