[Python-Dev] Very Strange Argument Handling Behavior

Daniel Stutzbach daniel at stutzbachenterprises.com
Fri Apr 16 23:42:17 CEST 2010


On Fri, Apr 16, 2010 at 4:11 PM, Raymond Hettinger <
raymond.hettinger at gmail.com> wrote:

> ISTM that making it illegal costs cycles with giving any real benefit.
> 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?
>

IIRC, there's a performance hack in dictobject.c that keeps track of whether
all of the keys are strings or not.  The hack is designed so that lookup
operations can call the string compare/hash functions directly if possible,
rather than going through the slower PyObject_ functions.

Consequently, validating **kwds should be cheap.

I don't know if the the current validating of **kwds with Python functions
already leverages that hack or not.
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100416/3d6b7b57/attachment.html>


More information about the Python-Dev mailing list