Someone rewrote pefile in Rust and its 121x faster
A new Python library called peoxide, written in Rust, has been released to significantly speed up parsing of Windows PE files while maintaining compatibility with the existing pefile standard.
peoxide is designed to read PE (Portable Executable) files, which are the standard format for Windows executables, DLLs, and other object files. The library can parse headers, sections, imports, and exports of Windows executables with attribute names matching the popular pefile library. Currently at version 0.0.1, peoxide ships a wheel for CPython 3.14 on 64-bit Windows, with source distribution available for other platforms.
Performance Benefits
The primary advantage of peoxide is its speed. By implementing the parser in Rust on top of the goblin library and making only one call into Rust per file (rather than one per field), peoxide achieves significantly faster performance than pefile, which is written in pure Python.
Compatibility and Differences
Despite being a new implementation, peoxide maintains familiar attribute names, types, and values that match pefile, allowing most read-only pefile code to work unchanged. However, there are intentional differences in how the two libraries handle certain edge cases. peoxide reports exactly what's in the file without adding conveniences or safety limits that pefile includes.
peoxide reports what is in the file. pefile adds a few conveniences and safety limits on top, so the two disagree in these cases.
Error Handling
A key feature of peoxide is its safe handling of bad input. Truncated, corrupted, or non-PE data raises a peoxide.PEFormatError without crashing the interpreter. The library has been tested against 2,000 randomly corrupted files to ensure robust error handling. This contrasts with pefile, which may behave unpredictably with malformed files.
Current Limitations
peoxide currently cannot modify or write PE files, focusing solely on reading them. The library requires Python 3.8 or newer and is primarily supported on Windows and Linux platforms. macOS arm64 wheels are not currently built, though Apple Silicon users can build from source. The project follows Semantic Versioning, with potential API breaks during 0.x minor releases.