There are actually three types of compiled files associated with Python: .pyc, .pyo, and .pyd. Let's go through the differences between them:
- .pyc: These are standard compiled bytecode files that can be used to make future module importing easier and faster
- .pyo: These are compiled bytecode files that are built with the -O (or -OO) option that is responsible for introducing optimizations affecting the speed they will be loaded (not executed)
- .pyd: These are traditional Windows DLL files that implement the MZ-PE structure (for Linux, it will be .so)
Since MZ-PE files have been covered multiple times throughout this book, we won't talk about them too much, nor spend much time on .pyd files. Their main feature is having a specific name for the initialization routine that should match the name of the module. Particularly, if you have a module named foo.pyd, it should export a function called initfoo so that later, when imported using the import foo statement, Python...