[Python-ideas] Preserving **kwargs order (was: Re: OrderedDict literals)

Franklin? Lee leewangzhong+python at gmail.com
Tue Apr 15 04:56:12 CEST 2014


Sigh. I couldn't figure out how to get GMail to fake its way into a thread
for emails I never got. How embarrassing.

Was trying to reply in this thread:
https://mail.python.org/pipermail/python-ideas/2014-April/027454.html

Anyway, I understand that Raymond Hettinger is implementing a better dict
that would inadvertently be ordered (
https://mail.python.org/pipermail/python-dev/2012-December/123028.html). I
am just wondering about whether the hashing algorithm or internal shape of
the automatic dictionary could be improved given what the interpreter can
guarantee about the keyspace.


On Mon, Apr 14, 2014 at 10:20 PM, Franklin? Lee <
leewangzhong+python at gmail.com> wrote:

> Would string interning help?
>
> As in, all keywords in a **pack have to be strings. All parameter names
> can be interned (if they're not already). The **pack can be a special dict
> optimized for strings (more specifically: identifiers), with an
> order-preserving overhead. (And then **unpacking would be smart about the
> type of thing being unpacked.)
>
> I understand that there would need to be a C proof-of-concept that this
> could act like a dict on the Python level, and maybe even beat a dict for
> **kwargs performance. I'm not suggesting that it's viable, but I haven't
> seen a mention of taking advantage of the restrictions on the keys, and
> while I personally got stuck trying to flesh out an algorithm and structure
> for it (unnecessary(?) overhead on extracting some keys and passing on the
> rest while preserving order), maybe someone more clever can figure out how
> to work it.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140414/77306f48/attachment.html>


More information about the Python-ideas mailing list