views:

222

answers:

1

Hi,

I'm using cx_Freeze to freeze my python program. On running cx_Freeze, a bunch of PYD files are created, a whole bunch of PYC files are put into a archive named library.zip and a few DLL files are there too.

Could someone tell me the difference between the PYC and the PYD files? What's the reason for the PYD files not in the library.zip? Is it possible to put the PYD files into the archive as well?

Thanks.

+1  A: 

Disclaimer: I haven't used cx_Freeze in awhile......

.PYD files are DLL machine-code files that contain specific python-required functions.

.PYC files are .py files that have been compiled into bytecode.

so PYDs are machine code and PYCs are bytecode

Now as for why the PYDs aren't in the .zip....I'd imagine it's because those .PYDs are needed by the python interpreter to run the program. What cx_Freeze does is basically this:

a) compile all .py files and throw the .pyc files in a zip b) put all needed .pyd files in the zip c) create a stub .py file and put it in the output directory d) copy the python.exe and rename to myprogram.exe e) copy all .pyd files needed to open the .zip and run the contents

So you're not actually compiling your python file, you're instead renaming the interpeter and freezing all the source files.

I hope this helps.

Timothy Baldridge
Thanks Tim. ..and all this while I've been thinking that I've been 'compiling' it into an exe. :p
Mridang Agarwalla
You might look into pypy. Pypy actually can compile your python code into C, but it's not exactly easy to setup/use/understand. http://codespeak.net/pypy/dist/pypy/doc/
Timothy Baldridge