[Python-Dev] repeated keyword arguments
Scott Dial
scott+python-dev at scottdial.com
Sat Jun 28 00:00:23 CEST 2008
Scott Dial wrote:
> The regression is purely in the way an argument list is reduced to a
> dictionary.
To further elaborate:
Python 2.4:
>>> import dis
>>> dis.dis(compile('f(a=3, b=1, a=4)', '', 'eval'))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
SyntaxError: duplicate keyword argument
Python 2.5:
>>> import dis
>>> dis.dis(compile('f(a=3, b=1, a=4)', '', 'eval'))
1 0 LOAD_NAME 0 (f)
3 LOAD_CONST 0 ('a')
6 LOAD_CONST 1 (3)
9 LOAD_CONST 2 ('b')
12 LOAD_CONST 3 (1)
15 LOAD_CONST 0 ('a')
18 LOAD_CONST 4 (4)
21 CALL_FUNCTION 768
24 RETURN_VALUE
The old compiler checked for this, but the AST-based compiler just
blindly compiles the entire keyword argument sequence.
-Scott
--
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu
More information about the Python-Dev
mailing list