Skip to content

Instantly share code, notes, and snippets.

@dpogue
Created December 24, 2010 23:30
Show Gist options
  • Save dpogue/754565 to your computer and use it in GitHub Desktop.
Save dpogue/754565 to your computer and use it in GitHub Desktop.
Python bytecode if/elif/else statements
0 LOAD_GLOBAL 0: kChatBroadcastMsg |
3 STORE_FAST 2: msgtype | msgtype = kChatBroadcastMsg
6 LOAD_FAST 1: flags |
9 LOAD_GLOBAL 3: kRTChatPrivate |
12 COMPARE_OP 2 |
,------ 15 JUMP_IF_FALSE 10 (to 28) | if (flags == kRTChatPrivate):
| 18 POP_TOP |
| 19 LOAD_GLOBAL 4: kChatPrivateMsg |
| 22 STORE_FAST 2: msgtype | msgtype = kChatPrivateMsg
,-------|------ 25 JUMP_FORWARD 47 (to 75) |
| `-----> 28 POP_TOP |
| 29 LOAD_FAST 1: flags |
| 32 LOAD_GLOBAL 5: kRTChatAdmin |
| 35 COMPARE_OP 2 |
| ,------ 38 JUMP_IF_FALSE 10 (to 51) | elif (flags == kRTChatAdmin):
| | 41 POP_TOP |
| | 42 LOAD_GLOBAL 6: kChatAdminBroadcastMsg |
| | 45 STORE_FAST 2: msgtype | msgtype = kChatAdminBroadcastMsg
|,------|------ 48 JUMP_FORWARD 24 (to 75) |
| `-----> 51 POP_TOP |
| 52 LOAD_FAST 1: flags |
| 55 LOAD_GLOBAL 7: kRTChatPrivateAdmin |
| 58 COMPARE_OP 2 |
| ,------ 61 JUMP_IF_FALSE 10 (to 74) | elif (flags == kRTChatPrivateAdmin):
| | 64 POP_TOP |
| | 65 LOAD_GLOBAL 8: kChatAdminPrivateMsg |
| | 68 STORE_FAST 2: msgtype | msgtype = kChatAdminPrivateMsg
|,------|------ 71 JUMP_FORWARD 1 (to 75) |
| `-----> 74 POP_TOP |
`-------------> 75 LOAD_FAST 2: msgtype |
78 RETURN_VALUE | return msgtype
79 LOAD_CONST 0: None |
82 RETURN_VALUE |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment