From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:PYC (Python compiled bytecode)" |
|---|
| claim | "Since Python 3.11 the magic numbers of Python 3.n start at 2900 + 50n and are incremented by 1 within the minor version for each format change, so the minor version of any 3.11+ pyc, including alpha and beta builds, is (magic - 2900) // 50 (3.11 = 3450-3499, 3.12 = 3500-3549, ... 3.16 = 3700-)." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:PYC (Python compiled bytecode)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | trigger | "reading the uint16 magic of a pyc" |
|---|
| effect | "minor version = (magic - 2900) // 50 for magic >= 3450" |
|---|
| condition | "Python 3.11 and later; older versions need the table of known values" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | ""Starting with Python 3.11, Python 3.n starts with magic number 2900+50n. Within each minor version, the magic number is incremented by 1 each time the file format changes."" |
|---|
| repo | "https://github.com/python/cpython" |
|---|
| commit | "010bebbf9fd12bba1e3f40bdbddacd51a9c2bf20" |
|---|
| path | "Include/internal/pycore_magic_number.h" |
|---|
| lines | "24-26" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "(3495-2900)//50 = 11 and (3531-2900)//50 = 12 match the CPython 3.11.15 and 3.12.8 that wrote them" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Magic number scheme from 3.11" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T05:12:29.173Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T06:52:28.125Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read pycore_magic_number.h at 010bebbf: header comment line 25 '3.n starts with 2900+50n', 3.11a1 3450, 3.12a1 3500, 3.13a1 3550, 3.15a0 3650, 3.16a0 3700." |
|---|
|
|
|---|