On Thu, Feb 12, 2015 at 6:13 AM, Steven D'Aprano <steve@pearwood.info> wrote:
I certainly wouldn't want to write

    new_dict = a + b + c + d

and have O(N**2) performance when I can do this instead

It would likely not be O(N), but O(N**2) seems exaggerated. Besides, the most common cases would be:


    new_dict = a + b
    old_dict += a

Both of which can be had in O(N).
 

    new_dict = {}
    for old_dict in (a, b, c, d):
        new_dict.update(old_dict)

It would be easier if we could do:

    new_dict = {}
    new_dict.update(a, b, c, d)

It would also be useful if dict.update() returned self, so this would be valid:

    new_dict = {}.update(a, b, c, d)

If that was so, then '+' could perhaps be implemented in terms of update() with the help of some smarts from the parser.

Cheers,

--
Juancarlo Añez