[New-bugs-announce] [issue23080] BoundArguments.arguments should be unordered

Antony Lee report at bugs.python.org
Thu Dec 18 13:56:29 CET 2014


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 <report at bugs.python.org>
<http://bugs.python.org/issue23080>
_______________________________________


More information about the New-bugs-announce mailing list