On Wed, Dec 16, 2015 at 10:47 AM, Mike Miller <python-ideas@mgmiller.net> wrote:
On 2015-12-15 11:02, Paul Moore wrote:
while it's a bit too special case on its own, one possibility would be to have
callable{k1: v1, k2: v2, ...}
be syntactic sugar for
callable([(k1, k1), (k2, v2), ...])
Very interesting... I've faced the issue several times over the years when I've wanted to unpack values into a function call in an ordered manner (but it hasn't been available). Perhaps::
callable{**odict}
In fact with callables I'd even go so far as wish that ordered unpacking was the default somehow, though I guess that probably isn't possible due to history.
That's not so clear, actually! It turns out that PyPy was able to make their regular 'dict' implementation ordered, while at the same time making it faster and more memory-efficient compared to their previous (CPython-like) implementation: http://morepypy.blogspot.com/2015/01/faster-more-memory-efficient-and-more.h... So in PyPy all these issues are automatically solved for free. The $1e6-question these other proposals have to answer is, why not do what PyPy did? Maybe there is a good reason not to, but it seems like it'll be difficult to get consensus on moving forward on any of these other more complicated proposals until someone has first made a serious attempt at porting PyPy's dict to CPython and is able to clearly describe why it didn't work. (3.5 does have a faster C implementation of OrderedDict, thanks to tireless efforts by Eric Snow -- https://bugs.python.org/issue16991 -- but this implementation uses a very different and less cache-efficient strategy than PyPy.) -n -- Nathaniel J. Smith -- http://vorpus.org