Windows How to make this gif code into an extension?

Never used it myself, so take this suggestion with a grain of salt. However, it seems like Cython might be able to convert Python code into C code. You should then be able to adapt the generated C code to be able to compile it successfully into a DLL that you can then load as an extension.