How mimetype detection works
masterThe library uses a hierarchical detection structure to optimize performance. This approach is particularly useful for container formats; for example, once a file is identified as a ZIP archive, the library skips generic checks (like text vs. binary) and instead checks if it matches specific container formats like Microsoft Office files.
To maintain efficiency and avoid loading entire files into memory, mimetype.DetectReader and mimetype.DetectFile only read the header of the input by default.