[Python-ideas] PEP: Dict addition and subtraction

Jonathan Fine jfine2358 at gmail.com
Wed Mar 6 07:31:13 EST 2019


Rhodri James wrote:

> Making assumptions about length where any dictionary
> manipulations are concerned seems unwise to me

I think you're a bit hasty here. Some assumptions are sensible. Suppose

    a = len(d1)
    b = len(d2)
    c = len(d1 + d2) # Using the suggested syntax.

Then we know
   max(a, b) <= c <= a + b

And this is, in broad terms, characteristic of merge operations.
-- 
Jonathan


More information about the Python-ideas mailing list