def read(filename: str) -> tuple[bytes, types.CodeType]:
with open(filename, "rb") as f:
# This is specific to Python version over 3.7, where the header is 16 bytes
# https://gist.github.com/stecman/3751ac494795164efa82a683130cabe5
# For reference:
# - Python 2.x uses a 2x 32-bit field header.
# - Python 3.2 changed to a 3x 32-bit field header.
# - And finally, the header size is 4 bytes longer from Python 3.7.
header = f.read(16)
code = marshal.load(f)
return (header, code)