{
  "id": "magic/python-pyc",
  "family": "magic",
  "slug": "python-pyc",
  "title": "Python bytecode (.pyc) signature",
  "summary": "A Python 3.7+ bytecode file (.pyc) begins with a 16-byte header: a 4-byte magic number (version-specific, e.g. 0xCB0D0DF3 for 3.11), a 4-byte null (flags), a 4-byte modification timestamp (or 0 for hash-based), and a 4-byte source file size (or hash).",
  "kind": "signature",
  "aliases": [
    "python-pyc magic",
    ".pyc",
    ".pyo"
  ],
  "status": "de-facto",
  "verification": "verified",
  "tier": "B",
  "source_url": "https://en.wikipedia.org/wiki/List_of_file_signatures",
  "source_version": "Wikipedia List of file signatures, retrieved 2026-05-29",
  "retrieved_date": "2026-05-29",
  "see_also": [],
  "ext_type": "file-signature@1",
  "ext": {
    "magic_hex": "CB 0D 0D F3",
    "offset": 0,
    "magic_ascii": "",
    "extensions": [
      "pyc",
      "pyo"
    ],
    "mime": "application/x-python-code",
    "spec": "Python import system (PEP 552)",
    "notes": [
      "Magic number varies by Python version (e.g. 0xCB0D0DF3 for 3.11, 0xA70D0DF3 for 3.10, 0x610D0DF3 for 3.9).",
      "Bytes 4-7: flags (0 = timestamp-based, 1 = hash-based).",
      "Bytes 8-11: mtime (timestamp-based) or first 4 bytes of the source hash.",
      "Bytes 12-15: source size (timestamp-based) or remaining hash bytes.",
      "The marshal module serializes the code object after the header."
    ]
  },
  "updated": "2026-05-29"
}
