Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/internal/pycore_magic_number.h
1 #ifndef Py_INTERNAL_MAGIC_NUMBER_H 2 #define Py_INTERNAL_MAGIC_NUMBER_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #ifndef Py_BUILD_CORE 8 # error "this header requires Py_BUILD_CORE define" 9 #endif 10 11 /* 12 13 Magic number to reject .pyc files generated by other Python versions. 14 It should change for each incompatible change to the bytecode. 15 16 PYC_MAGIC_NUMBER must change whenever the bytecode emitted by the compiler may 17 no longer be understood by older implementations of the eval loop (usually due 18 to the addition of new opcodes). 19 20 The value of CR and LF is incorporated so if you ever read or write 21 a .pyc file in text mode the magic number will be wrong; also, the 22 Apple MPW compiler swaps their values, botching string constants. 23 24 There were a variety of old schemes for setting the magic number. Starting with 25 Python 3.11, Python 3.n starts with magic number 2900+50n. Within each minor 26 version, the magic number is incremented by 1 each time the file format changes. 27 28 Known values: 29 Python 1.5: 20121 30 Python 1.5.1: 20121 31 Python 1.5.2: 20121 32 Python 1.6: 50428 33 Python 2.0: 50823 34 Python 2.0.1: 50823 35 Python 2.1: 60202 36 Python 2.1.1: 60202 37 Python 2.1.2: 60202 38 Python 2.2: 60717 39 Python 2.3a0: 62011 40 Python 2.3a0: 62021 41 Python 2.3a0: 62011 (!) 42 Python 2.4a0: 62041 43 Python 2.4a3: 62051 44 Python 2.4b1: 62061 45 Python 2.5a0: 62071 46 Python 2.5a0: 62081 (ast-branch) 47 Python 2.5a0: 62091 (with) 48 Python 2.5a0: 62092 (changed WITH_CLEANUP opcode) 49 Python 2.5b3: 62101 (fix wrong code: for x, in ...) 50 Python 2.5b3: 62111 (fix wrong code: x += yield) 51 Python 2.5c1: 62121 (fix wrong lnotab with for loops and 52 storing constants that should have been removed) 53 Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) 54 Python 2.6a0: 62151 (peephole optimizations and STORE_MAP opcode) 55 Python 2.6a1: 62161 (WITH_CLEANUP optimization) 56 Python 2.7a0: 62171 (optimize list comprehensions/change LIST_APPEND) 57 Python 2.7a0: 62181 (optimize conditional branches: 58 introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE) 59 Python 2.7a0 62191 (introduce SETUP_WITH) 60 Python 2.7a0 62201 (introduce BUILD_SET) 61 Python 2.7a0 62211 (introduce MAP_ADD and SET_ADD) 62 Python 3000: 3000 63 3010 (removed UNARY_CONVERT) 64 3020 (added BUILD_SET) 65 3030 (added keyword-only parameters) 66 3040 (added signature annotations) 67 3050 (print becomes a function) 68 3060 (PEP 3115 metaclass syntax) 69 3061 (string literals become unicode) 70 3071 (PEP 3109 raise changes) 71 3081 (PEP 3137 make __file__ and __name__ unicode) 72 3091 (kill str8 interning) 73 3101 (merge from 2.6a0, see 62151) 74 3103 (__file__ points to source file) 75 Python 3.0a4: 3111 (WITH_CLEANUP optimization). 76 Python 3.0b1: 3131 (lexical exception stacking, including POP_EXCEPT 77 #3021) 78 Python 3.1a1: 3141 (optimize list, set and dict comprehensions: 79 change LIST_APPEND and SET_ADD, add MAP_ADD #2183) 80 Python 3.1a1: 3151 (optimize conditional branches: 81 introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE 82 #4715) 83 Python 3.2a1: 3160 (add SETUP_WITH #6101) 84 Python 3.2a2: 3170 (add DUP_TOP_TWO, remove DUP_TOPX and ROT_FOUR #9225) 85 Python 3.2a3 3180 (add DELETE_DEREF #4617) 86 Python 3.3a1 3190 (__class__ super closure changed) 87 Python 3.3a1 3200 (PEP 3155 __qualname__ added #13448) 88 Python 3.3a1 3210 (added size modulo 2**32 to the pyc header #13645) 89 Python 3.3a2 3220 (changed PEP 380 implementation #14230) 90 Python 3.3a4 3230 (revert changes to implicit __class__ closure #14857) 91 Python 3.4a1 3250 (evaluate positional default arguments before 92 keyword-only defaults #16967) 93 Python 3.4a1 3260 (add LOAD_CLASSDEREF; allow locals of class to override 94 free vars #17853) 95 Python 3.4a1 3270 (various tweaks to the __class__ closure #12370) 96 Python 3.4a1 3280 (remove implicit class argument) 97 Python 3.4a4 3290 (changes to __qualname__ computation #19301) 98 Python 3.4a4 3300 (more changes to __qualname__ computation #19301) 99 Python 3.4rc2 3310 (alter __qualname__ computation #20625) 100 Python 3.5a1 3320 (PEP 465: Matrix multiplication operator #21176) 101 Python 3.5b1 3330 (PEP 448: Additional Unpacking Generalizations #2292) 102 Python 3.5b2 3340 (fix dictionary display evaluation order #11205) 103 Python 3.5b3 3350 (add GET_YIELD_FROM_ITER opcode #24400) 104 Python 3.5.2 3351 (fix BUILD_MAP_UNPACK_WITH_CALL opcode #27286) 105 Python 3.6a0 3360 (add FORMAT_VALUE opcode #25483) 106 Python 3.6a1 3361 (lineno delta of code.co_lnotab becomes signed #26107) 107 Python 3.6a2 3370 (16 bit wordcode #26647) 108 Python 3.6a2 3371 (add BUILD_CONST_KEY_MAP opcode #27140) 109 Python 3.6a2 3372 (MAKE_FUNCTION simplification, remove MAKE_CLOSURE 110 #27095) 111 Python 3.6b1 3373 (add BUILD_STRING opcode #27078) 112 Python 3.6b1 3375 (add SETUP_ANNOTATIONS and STORE_ANNOTATION opcodes 113 #27985) 114 Python 3.6b1 3376 (simplify CALL_FUNCTIONs & BUILD_MAP_UNPACK_WITH_CALL 115 #27213) 116 Python 3.6b1 3377 (set __class__ cell from type.__new__ #23722) 117 Python 3.6b2 3378 (add BUILD_TUPLE_UNPACK_WITH_CALL #28257) 118 Python 3.6rc1 3379 (more thorough __class__ validation #23722) 119 Python 3.7a1 3390 (add LOAD_METHOD and CALL_METHOD opcodes #26110) 120 Python 3.7a2 3391 (update GET_AITER #31709) 121 Python 3.7a4 3392 (PEP 552: Deterministic pycs #31650) 122 Python 3.7b1 3393 (remove STORE_ANNOTATION opcode #32550) 123 Python 3.7b5 3394 (restored docstring as the first stmt in the body; 124 this might affected the first line number #32911) 125 Python 3.8a1 3400 (move frame block handling to compiler #17611) 126 Python 3.8a1 3401 (add END_ASYNC_FOR #33041) 127 Python 3.8a1 3410 (PEP570 Python Positional-Only Parameters #36540) 128 Python 3.8b2 3411 (Reverse evaluation order of key: value in dict 129 comprehensions #35224) 130 Python 3.8b2 3412 (Swap the position of positional args and positional 131 only args in ast.arguments #37593) 132 Python 3.8b4 3413 (Fix "break" and "continue" in "finally" #37830) 133 Python 3.9a0 3420 (add LOAD_ASSERTION_ERROR #34880) 134 Python 3.9a0 3421 (simplified bytecode for with blocks #32949) 135 Python 3.9a0 3422 (remove BEGIN_FINALLY, END_FINALLY, CALL_FINALLY, POP_FINALLY bytecodes #33387) 136 Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) 137 Python 3.9a2 3424 (simplify bytecodes for *value unpacking) 138 Python 3.9a2 3425 (simplify bytecodes for **value unpacking) 139 Python 3.10a1 3430 (Make 'annotations' future by default) 140 Python 3.10a1 3431 (New line number table format -- PEP 626) 141 Python 3.10a2 3432 (Function annotation for MAKE_FUNCTION is changed from dict to tuple bpo-42202) 142 Python 3.10a2 3433 (RERAISE restores f_lasti if oparg != 0) 143 Python 3.10a6 3434 (PEP 634: Structural Pattern Matching) 144 Python 3.10a7 3435 Use instruction offsets (as opposed to byte offsets). 145 Python 3.10b1 3436 (Add GEN_START bytecode #43683) 146 Python 3.10b1 3437 (Undo making 'annotations' future by default - We like to dance among core devs!) 147 Python 3.10b1 3438 Safer line number table handling. 148 Python 3.10b1 3439 (Add ROT_N) 149 Python 3.11a1 3450 Use exception table for unwinding ("zero cost" exception handling) 150 Python 3.11a1 3451 (Add CALL_METHOD_KW) 151 Python 3.11a1 3452 (drop nlocals from marshaled code objects) 152 Python 3.11a1 3453 (add co_fastlocalnames and co_fastlocalkinds) 153 Python 3.11a1 3454 (compute cell offsets relative to locals bpo-43693) 154 Python 3.11a1 3455 (add MAKE_CELL bpo-43693) 155 Python 3.11a1 3456 (interleave cell args bpo-43693) 156 Python 3.11a1 3457 (Change localsplus to a bytes object bpo-43693) 157 Python 3.11a1 3458 (imported objects now don't use LOAD_METHOD/CALL_METHOD) 158 Python 3.11a1 3459 (PEP 657: add end line numbers and column offsets for instructions) 159 Python 3.11a1 3460 (Add co_qualname field to PyCodeObject bpo-44530) 160 Python 3.11a1 3461 (JUMP_ABSOLUTE must jump backwards) 161 Python 3.11a2 3462 (bpo-44511: remove COPY_DICT_WITHOUT_KEYS, change 162 MATCH_CLASS and MATCH_KEYS, and add COPY) 163 Python 3.11a3 3463 (bpo-45711: JUMP_IF_NOT_EXC_MATCH no longer pops the 164 active exception) 165 Python 3.11a3 3464 (bpo-45636: Merge numeric BINARY_*INPLACE_* into 166 BINARY_OP) 167 Python 3.11a3 3465 (Add COPY_FREE_VARS opcode) 168 Python 3.11a4 3466 (bpo-45292: PEP-654 except*) 169 Python 3.11a4 3467 (Change CALL_xxx opcodes) 170 Python 3.11a4 3468 (Add SEND opcode) 171 Python 3.11a4 3469 (bpo-45711: remove type, traceback from exc_info) 172 Python 3.11a4 3470 (bpo-46221: PREP_RERAISE_STAR no longer pushes lasti) 173 Python 3.11a4 3471 (bpo-46202: remove pop POP_EXCEPT_AND_RERAISE) 174 Python 3.11a4 3472 (bpo-46009: replace GEN_START with POP_TOP) 175 Python 3.11a4 3473 (Add POP_JUMP_IF_NOT_NONE/POP_JUMP_IF_NONE opcodes) 176 Python 3.11a4 3474 (Add RESUME opcode) 177 Python 3.11a5 3475 (Add RETURN_GENERATOR opcode) 178 Python 3.11a5 3476 (Add ASYNC_GEN_WRAP opcode) 179 Python 3.11a5 3477 (Replace DUP_TOP/DUP_TOP_TWO with COPY and 180 ROT_TWO/ROT_THREE/ROT_FOUR/ROT_N with SWAP) 181 Python 3.11a5 3478 (New CALL opcodes) 182 Python 3.11a5 3479 (Add PUSH_NULL opcode) 183 Python 3.11a5 3480 (New CALL opcodes, second iteration) 184 Python 3.11a5 3481 (Use inline cache for BINARY_OP) 185 Python 3.11a5 3482 (Use inline caching for UNPACK_SEQUENCE and LOAD_GLOBAL) 186 Python 3.11a5 3483 (Use inline caching for COMPARE_OP and BINARY_SUBSCR) 187 Python 3.11a5 3484 (Use inline caching for LOAD_ATTR, LOAD_METHOD, and 188 STORE_ATTR) 189 Python 3.11a5 3485 (Add an oparg to GET_AWAITABLE) 190 Python 3.11a6 3486 (Use inline caching for PRECALL and CALL) 191 Python 3.11a6 3487 (Remove the adaptive "oparg counter" mechanism) 192 Python 3.11a6 3488 (LOAD_GLOBAL can push additional NULL) 193 Python 3.11a6 3489 (Add JUMP_BACKWARD, remove JUMP_ABSOLUTE) 194 Python 3.11a6 3490 (remove JUMP_IF_NOT_EXC_MATCH, add CHECK_EXC_MATCH) 195 Python 3.11a6 3491 (remove JUMP_IF_NOT_EG_MATCH, add CHECK_EG_MATCH, 196 add JUMP_BACKWARD_NO_INTERRUPT, make JUMP_NO_INTERRUPT virtual) 197 Python 3.11a7 3492 (make POP_JUMP_IF_NONE/NOT_NONE/TRUE/FALSE relative) 198 Python 3.11a7 3493 (Make JUMP_IF_TRUE_OR_POP/JUMP_IF_FALSE_OR_POP relative) 199 Python 3.11a7 3494 (New location info table) 200 Python 3.11b4 3495 (Set line number of module's RESUME instr to 0 per PEP 626) 201 Python 3.12a1 3500 (Remove PRECALL opcode) 202 Python 3.12a1 3501 (YIELD_VALUE oparg == stack_depth) 203 Python 3.12a1 3502 (LOAD_FAST_CHECK, no NULL-check in LOAD_FAST) 204 Python 3.12a1 3503 (Shrink LOAD_METHOD cache) 205 Python 3.12a1 3504 (Merge LOAD_METHOD back into LOAD_ATTR) 206 Python 3.12a1 3505 (Specialization/Cache for FOR_ITER) 207 Python 3.12a1 3506 (Add BINARY_SLICE and STORE_SLICE instructions) 208 Python 3.12a1 3507 (Set lineno of module's RESUME to 0) 209 Python 3.12a1 3508 (Add CLEANUP_THROW) 210 Python 3.12a1 3509 (Conditional jumps only jump forward) 211 Python 3.12a2 3510 (FOR_ITER leaves iterator on the stack) 212 Python 3.12a2 3511 (Add STOPITERATION_ERROR instruction) 213 Python 3.12a2 3512 (Remove all unused consts from code objects) 214 Python 3.12a4 3513 (Add CALL_INTRINSIC_1 instruction, removed STOPITERATION_ERROR, PRINT_EXPR, IMPORT_STAR) 215 Python 3.12a4 3514 (Remove ASYNC_GEN_WRAP, LIST_TO_TUPLE, and UNARY_POSITIVE) 216 Python 3.12a5 3515 (Embed jump mask in COMPARE_OP oparg) 217 Python 3.12a5 3516 (Add COMPARE_AND_BRANCH instruction) 218 Python 3.12a5 3517 (Change YIELD_VALUE oparg to exception block depth) 219 Python 3.12a6 3518 (Add RETURN_CONST instruction) 220 Python 3.12a6 3519 (Modify SEND instruction) 221 Python 3.12a6 3520 (Remove PREP_RERAISE_STAR, add CALL_INTRINSIC_2) 222 Python 3.12a7 3521 (Shrink the LOAD_GLOBAL caches) 223 Python 3.12a7 3522 (Removed JUMP_IF_FALSE_OR_POP/JUMP_IF_TRUE_OR_POP) 224 Python 3.12a7 3523 (Convert COMPARE_AND_BRANCH back to COMPARE_OP) 225 Python 3.12a7 3524 (Shrink the BINARY_SUBSCR caches) 226 Python 3.12b1 3525 (Shrink the CALL caches) 227 Python 3.12b1 3526 (Add instrumentation support) 228 Python 3.12b1 3527 (Add LOAD_SUPER_ATTR) 229 Python 3.12b1 3528 (Add LOAD_SUPER_ATTR_METHOD specialization) 230 Python 3.12b1 3529 (Inline list/dict/set comprehensions) 231 Python 3.12b1 3530 (Shrink the LOAD_SUPER_ATTR caches) 232 Python 3.12b1 3531 (Add PEP 695 changes) 233 Python 3.13a1 3550 (Plugin optimizer support) 234 Python 3.13a1 3551 (Compact superinstructions) 235 Python 3.13a1 3552 (Remove LOAD_FAST__LOAD_CONST and LOAD_CONST__LOAD_FAST) 236 Python 3.13a1 3553 (Add SET_FUNCTION_ATTRIBUTE) 237 Python 3.13a1 3554 (more efficient bytecodes for f-strings) 238 Python 3.13a1 3555 (generate specialized opcodes metadata from bytecodes.c) 239 Python 3.13a1 3556 (Convert LOAD_CLOSURE to a pseudo-op) 240 Python 3.13a1 3557 (Make the conversion to boolean in jumps explicit) 241 Python 3.13a1 3558 (Reorder the stack items for CALL) 242 Python 3.13a1 3559 (Generate opcode IDs from bytecodes.c) 243 Python 3.13a1 3560 (Add RESUME_CHECK instruction) 244 Python 3.13a1 3561 (Add cache entry to branch instructions) 245 Python 3.13a1 3562 (Assign opcode IDs for internal ops in separate range) 246 Python 3.13a1 3563 (Add CALL_KW and remove KW_NAMES) 247 Python 3.13a1 3564 (Removed oparg from YIELD_VALUE, changed oparg values of RESUME) 248 Python 3.13a1 3565 (Oparg of YIELD_VALUE indicates whether it is in a yield-from) 249 Python 3.13a1 3566 (Emit JUMP_NO_INTERRUPT instead of JUMP for non-loop no-lineno cases) 250 Python 3.13a1 3567 (Reimplement line number propagation by the compiler) 251 Python 3.13a1 3568 (Change semantics of END_FOR) 252 Python 3.13a5 3569 (Specialize CONTAINS_OP) 253 Python 3.13a6 3570 (Add __firstlineno__ class attribute) 254 Python 3.13b1 3571 (Fix miscompilation of private names in generic classes) 255 Python 3.14a1 3600 (Add LOAD_COMMON_CONSTANT) 256 Python 3.14a1 3601 (Fix miscompilation of private names in generic classes) 257 Python 3.14a1 3602 (Add LOAD_SPECIAL. Remove BEFORE_WITH and BEFORE_ASYNC_WITH) 258 Python 3.14a1 3603 (Remove BUILD_CONST_KEY_MAP) 259 Python 3.14a1 3604 (Do not duplicate test at end of while statements) 260 Python 3.14a1 3605 (Move ENTER_EXECUTOR to opcode 255) 261 Python 3.14a1 3606 (Specialize CALL_KW) 262 Python 3.14a1 3607 (Add pseudo instructions JUMP_IF_TRUE/FALSE) 263 Python 3.14a1 3608 (Add support for slices) 264 Python 3.14a2 3609 (Add LOAD_SMALL_INT and LOAD_CONST_IMMORTAL instructions, remove RETURN_CONST) 265 Python 3.14a4 3610 (Add VALUE_WITH_FAKE_GLOBALS format to annotationlib) 266 Python 3.14a4 3611 (Add NOT_TAKEN instruction) 267 Python 3.14a4 3612 (Add POP_ITER and INSTRUMENTED_POP_ITER) 268 Python 3.14a4 3613 (Add LOAD_CONST_MORTAL instruction) 269 Python 3.14a5 3614 (Add BINARY_OP_EXTEND) 270 Python 3.14a5 3615 (CALL_FUNCTION_EX always take a kwargs argument) 271 Python 3.14a5 3616 (Remove BINARY_SUBSCR and family. Make them BINARY_OPs) 272 Python 3.14a6 3617 (Branch monitoring for async for loops) 273 Python 3.14a6 3618 (Add oparg to END_ASYNC_FOR) 274 Python 3.14a6 3619 (Renumber RESUME opcode from 149 to 128) 275 Python 3.14a6 3620 (Optimize bytecode for all/any/tuple called on a genexp) 276 Python 3.14a7 3621 (Optimize LOAD_FAST opcodes into LOAD_FAST_BORROW) 277 Python 3.14a7 3622 (Store annotations in different class dict keys) 278 Python 3.14a7 3623 (Add BUILD_INTERPOLATION & BUILD_TEMPLATE opcodes) 279 Python 3.14b1 3624 (Don't optimize LOAD_FAST when local is killed by DELETE_FAST) 280 Python 3.14b3 3625 (Fix handling of opcodes that may leave operands on the stack when optimizing LOAD_FAST) 281 Python 3.14rc2 3626 (Fix missing exception handlers in logical expression) 282 Python 3.14rc3 3627 (Fix miscompilation of some module-level annotations) 283 284 Python 3.15 will start with 3650 285 286 Please don't copy-paste the same pre-release tag for new entries above!!! 287 You should always use the *upcoming* tag. For example, if 3.12a6 came out 288 a week ago, I should put "Python 3.12a7" next to my new magic number. 289 290 Whenever PYC_MAGIC_NUMBER is changed, the ranges in the magic_values array in 291 PC/launcher.c must also be updated. 292 293 */ 294 295 #define PYC_MAGIC_NUMBER 3627 296 /* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes 297 (little-endian) and then appending b'\r\n'. */ 298 #define PYC_MAGIC_NUMBER_TOKEN \ 299 ((uint32_t)PYC_MAGIC_NUMBER | ((uint32_t)'\r' << 16) | ((uint32_t)'\n' << 24)) 300 301 302 #ifdef __cplusplus 303 } 304 #endif 305 #endif // !Py_INTERNAL_MAGIC_NUMBER_H