[Python-ideas] Collect **kw arguments as an ordered dictionary
Raymond Hettinger
python at rcn.com
Sat Apr 18 00:09:51 CEST 2009
[Michael Foord]
> It would be nice if **kw arguments collected in a function / method signature
> were collected as an ordered dictionary rather than ordinary dictionary.
I think that would be nice, but until ordered dicts get a C implementation,
it might greatly impair performance.
> Main use case, currently (I believe) the odict constructor doesn't guarantee
> to preserve ordering if created with keyword arguments:
That is correct. And so noted in the docs:
http://docs.python.org/dev/library/collections.html#ordereddict-objects
> My use case - I'd like to preserve the ordering to reproduce exactly the
> order of arguments for the Mock module representation of the objects
> are used. Because the order of iterating over arguments isn't the same
> as they are passed in representations can't be compared in tests
> reliably across Python versions / implementations.
Sounds reasonable.
Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090417/94e43fee/attachment.html>
More information about the Python-ideas
mailing list