New submission from Antony Lee: This patch makes BoundArguments.arguments an unordered dict. As discussed on python-ideas, the rationale for this is
1. The current ordering in ba.arguments is the one of the parameters in the signature (which is already available via the ba.signature attribute), not the one in which the arguments are given (which will always be unavailable as long as Python doesn't keep the order of keyword arguments), so no information is lost by this patch. 2. The recipe in the docs for updating ba.arguments to also contain default argument values breaks that ordering, making __eq__ behavior difficult to explain: s = signature(lambda x=None, y=None: None) ba0 = s.bind() ba1 = s.bind(x=None) ba2 = s.bind(y=None) <add default values as suggested in the docs> At that point, with the current implementation, we'll have ba0 == ba1 != ba2... why? 3. Implementing ba.arguments as a regular dict makes signature.bind much faster, which is important e.g. if it is used in a decorating type-checker as suggested in PEP362. (That specific issue could also be improved by a C-implemented OrderedDict, but the other reasons remain valid.) ---------- components: Library (Lib) files: unordered-boundarguments.patch keywords: patch messages: 232874 nosy: Antony.Lee priority: normal severity: normal status: open title: BoundArguments.arguments should be unordered versions: Python 3.5 Added file: http://bugs.python.org/file37492/unordered-boundarguments.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23080> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com