[Python-Dev] Very Strange Argument Handling Behavior

Guido van Rossum guido at python.org
Fri Apr 16 23:16:51 CEST 2010


On Fri, Apr 16, 2010 at 2:11 PM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
>
>>> Guido van Rossum, 16.04.2010 16:33:
>>>>
>>>> I am fine with
>>>> declaring dict({}, **{1:3}) illegal, since after all it is abuse of
>>>> the ** mechanism.
>
> ISTM that making it illegal costs cycles with giving any real benefit.

Diasagree. The real benefit is better cross-implementation portability.

> It is reasonably common to accept **kwds and then pass it down
> to another function.  Do we want to validate the keys of every
> kwds dict on every call?  Why do we even care?
>
> If I'm understanding the proposal correctly, it means that
> every existing application using **kwds will pay a price, either
> by breaking (because it uses non-string keys) or by running
> slower (so that every call can be checked to make sure it
> didn't use string keys).

It already does this for Python functions. So there is no cost (and no
change in the language semantics) except for the specific idiom
involving dict, which was incorrectly taking a shortcut.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list