[Python-checkins] r63965 - python/trunk/Lib/tokenize.py

skip at pobox.com skip at pobox.com
Mon Jun 9 18:12:37 CEST 2008


 Benjamin> Thanks for letting me know. It's still using while 1 in
 Benjamin> 3.0. Shall I revert the 2.6 revision, and change it in 3.0?
That would seem to make sense. Python 2.6:
 >>> import dis
 >>> def while1():
 ... while 1:
 ... pass
 ... 
 >>> dis.dis(while1)
 2 0 SETUP_LOOP 3 (to 6)
 3 >> 3 JUMP_ABSOLUTE 3
 >> 6 LOAD_CONST 0 (None)
 9 RETURN_VALUE 
 >>> def whileTrue():
 ... while True:
 ... pass
 ... 
 >>> dis.dis(whileTrue)
 2 0 SETUP_LOOP 12 (to 15)
 >> 3 LOAD_GLOBAL 0 (True)
 6 JUMP_IF_FALSE 4 (to 13)
 9 POP_TOP 
 3 10 JUMP_ABSOLUTE 3
 >> 13 POP_TOP 
 14 POP_BLOCK 
 >> 15 LOAD_CONST 0 (None)
 18 RETURN_VALUE 
Python 3.0:
 >>> import dis
 >>> def while1():
 ... while 1:
 ... pass
 ... 
 >>> dis.dis(while1)
 2 0 SETUP_LOOP 3 (to 6) 
 3 >> 3 JUMP_ABSOLUTE 3 
 >> 6 LOAD_CONST 0 (None) 
 9 RETURN_VALUE 
 >>> def whileTrue():
 ... while True:
 ... pass
 ... 
 >>> dis.dis(whileTrue)
 2 0 SETUP_LOOP 3 (to 6) 
 3 >> 3 JUMP_ABSOLUTE 3 
 >> 6 LOAD_CONST 0 (None) 
 9 RETURN_VALUE 
Skip


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /