Message22743
Logged In: YES
user_id=80475
Under the hood, the compiler is recognizing that the
function bodies are identical and it produces just one code
object instead of two. Hence, the co_firstline number with
always reflect the first time the code is defined.
A simple demo shows the id being the same when the bodies
are identical:
src = """
f1 = lambda x=1: x
f2 = lambda x=2: x
"""
from dis import dis
c = compile(src, 'example', 'exec')
dis(c)
For the OP's code, the effect can be shown by
differentiating either lambda body by adding zero to the pop
index:
nextkey1 = lambda N=keynums1,K=key_src: K[N.pop()+0]
I conclude that there is less to the bug than meets the eye
and that it may even be considered a feature. Referring to
Jeremy for final disposition. |
|
Date |
User |
Action |
Args |
2007-08-23 14:26:47 | admin | link | issue1048870 messages |
2007-08-23 14:26:47 | admin | create | |
|