[Python-Dev] (no subject)

Victor Stinner victor.stinner at gmail.com
Tue Feb 10 02:14:20 CET 2015


2015-02-10 1:29 GMT+01:00 Neil Girdhar <mistersheik at gmail.com>:
> For some reason I can't seem to reply using Google groups, which is is
> telling "this is a read-only mirror" (anyone know why?)  Anyway, I'm going
> to answer as best I can the concerns.
>
> Antoine said:
>
>> To be clear, the PEP will probably be useful for one single line of
>> Python code every 10000. This is a very weak case for such an intrusive
>> syntax addition. I would support the PEP if it only added the simple
>> cases of tuple unpacking, left alone function call conventions, and
>> didn't introduce **-unpacking.
>
>
> To me this is more of a syntax simplification than a syntax addition.  For
> me the **-unpacking is the most useful part. Regarding utility, it seems
> that a many of the people on r/python were pretty excited about this PEP:
> http://www.reddit.com/r/Python/comments/2synry/so_8_peps_are_currently_being_proposed_for_python/

I used grep to find how many times dict.update() is used.

haypo at selma$ wc -l Lib/*.py
(....)
 112055 total
haypo at selma$ grep '\.update(.\+)' Lib/*.py|wc -l
63

So there are 63 or less (it's a regex, I didn't check each line) calls
to dict.update() on a total of 112,055 lines.

I found a few numbers of codes using the pattern:
"dict1.update(dict2); func(**dict1)". Examples:


functools.py:

def partial(func, *args, **keywords):
    def newfunc(*fargs, **fkeywords):
        newkeywords = keywords.copy()
        newkeywords.update(fkeywords)
        return func(*(args + fargs), **newkeywords)
    ...
    return newfunc

=>

def partial(func, *args, **keywords):
    def newfunc(*fargs, **fkeywords):
        return func(*(args + fargs), **keywords, **fkeywords)
    ...
    return newfunc

The new code behaves differently since Neil said that an error is
raised if fkeywords and keywords have keys in common. By the way, this
must be written in the PEP.


pdb.py:

        ns = self.curframe.f_globals.copy()
        ns.update(self.curframe_locals)
        code.interact("*interactive*", local=ns)

Hum no sorry, ns is not used with ** here.

Victor


More information about the Python-Dev mailing list