From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "magic" |
|---|
| subject | "Format:PYC (Python compiled bytecode)" |
|---|
| claim | "Every CPython .pyc starts with a 2-byte little-endian magic number followed by CR LF (0D 0A); the magic number identifies the bytecode revision, e.g. A7 0D 0D 0A for Python 3.11 and CB 0D 0D 0A for 3.12." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:PYC (Python compiled bytecode)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | bytes | "00 00 0D 0A" |
|---|
| mask | "00 00 FF FF" |
|---|
| offset | 0 |
|---|
| meaning | "uint16 LE magic number (bytecode revision) + CR LF" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "PYC_MAGIC_NUMBER_TOKEN = magic | '\r' << 16 | '\n' << 24" |
|---|
| repo | "https://github.com/python/cpython" |
|---|
| commit | "010bebbf9fd12bba1e3f40bdbddacd51a9c2bf20" |
|---|
| path | "Include/internal/pycore_magic_number.h" |
|---|
| lines | "316-320" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "importlib.util.MAGIC_NUMBER is a7 0d 0d 0a on CPython 3.11.15 and cb 0d 0d 0a on 3.12.8; py_compile output starts with these bytes" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "PYC magic" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T05:12:29.000Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T11:56:55.846Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read pycore_magic_number.h lines 316-320: PYC_MAGIC_NUMBER_TOKEN = magic | '\r'<<16 | '\n'<<24, i.e. a u16 LE number then 0D 0A; at this commit the number is 3706 (7A 0E 0D 0A), the fact's mask 00 00 FF FF is right and 3495/3531 equal A7 0D / CB 0D" |
|---|
|
|
|---|