H
higer
My Python version is 2.5.2; When I reading the bytecode of some pyc
file, I always found that there are many jump command from different
position,but to the same position. You can see this situation in
following code(this bytecode is just from one .pyc file and I don't
have its source .py file):
......
526 POP_TOP ''
527 LOAD_FAST 'imeHandle'
530 LOAD_ATTR 'isCnInput'
533 CALL_FUNCTION_0 ''
536 JUMP_IF_FALSE '574'
539 POP_TOP ''
540 LOAD_FAST 'GUIDefine'
543 LOAD_ATTR 'CandidateIsOpen'
546 JUMP_IF_TRUE '574'
549 POP_TOP ''
550 LOAD_FAST 'GUIDefine'
553 LOAD_ATTR 'CompositionWndIsOpen'
556 JUMP_IF_TRUE '574'
559 POP_TOP ''
560 LOAD_FAST 'isWanNengWB'
563 JUMP_IF_FALSE '574'
566 POP_TOP ''
567 LOAD_FAST 'state'
570 LOAD_CONST 1
573 BINARY_AND ''
574_0 COME_FROM ''
574_1 COME_FROM ''
574_2 COME_FROM ''
574_3 COME_FROM ''
....
From the above bytecode,we know that line 574 is the point that many
position jumps to.So,it just looks like the 'goto' function in C, but
we know that there is none such function in Python.
One 'JUMP**' command is companied with a 'COME_FROM' command,so more
than one 'COME_FROM' OPs are listed on line 574...
But ,the question is, I have tried a lot of ways(e.g.for loop,while
loop and mixed) to re-present 'goto' style bytecodes like this, but
the result depressed me.
So,I think maybe it is just a compiler optimization in Python2.5? I'm
not sure,so I'm appreciated that if anyone can help me.
file, I always found that there are many jump command from different
position,but to the same position. You can see this situation in
following code(this bytecode is just from one .pyc file and I don't
have its source .py file):
......
526 POP_TOP ''
527 LOAD_FAST 'imeHandle'
530 LOAD_ATTR 'isCnInput'
533 CALL_FUNCTION_0 ''
536 JUMP_IF_FALSE '574'
539 POP_TOP ''
540 LOAD_FAST 'GUIDefine'
543 LOAD_ATTR 'CandidateIsOpen'
546 JUMP_IF_TRUE '574'
549 POP_TOP ''
550 LOAD_FAST 'GUIDefine'
553 LOAD_ATTR 'CompositionWndIsOpen'
556 JUMP_IF_TRUE '574'
559 POP_TOP ''
560 LOAD_FAST 'isWanNengWB'
563 JUMP_IF_FALSE '574'
566 POP_TOP ''
567 LOAD_FAST 'state'
570 LOAD_CONST 1
573 BINARY_AND ''
574_0 COME_FROM ''
574_1 COME_FROM ''
574_2 COME_FROM ''
574_3 COME_FROM ''
....
From the above bytecode,we know that line 574 is the point that many
position jumps to.So,it just looks like the 'goto' function in C, but
we know that there is none such function in Python.
One 'JUMP**' command is companied with a 'COME_FROM' command,so more
than one 'COME_FROM' OPs are listed on line 574...
But ,the question is, I have tried a lot of ways(e.g.for loop,while
loop and mixed) to re-present 'goto' style bytecodes like this, but
the result depressed me.
So,I think maybe it is just a compiler optimization in Python2.5? I'm
not sure,so I'm appreciated that if anyone can help me.