[IronPython] Snippets

Jim Hugunin jim at ironpython.com
Wed Oct 20 01:12:25 CEST 2004

Jon Cosby wrote:
> What are "snippets" and "__main__" in the IronPython bin? They don't
> appear
> to be necessary to run the application, but I could be missing something.

These files are generated by running a Python script.  The ones in the .zip
file are there because I didn't fully clean-up after running some tests just
before shipping.  If you run your own Python script you'll find that these
two files get created.  If you're interested in better understanding how
IronPython works, these files can be very valuable.

__main__.exe is the compiled form of whatever Python script you run.
__main__ is the name given to the executing module when you run a script on
the commandline.  If you import other Python modules, they will have
corresponding compiled files created.  These files are equivalent to
standard CPython's .pyc files except that they hold IL bytecode for the CLR
instead of Python-specific bytecodes.

snippets.dll will only be written to disk after a run of Python completes.
It will even be generated after running at the interactive interpreter
prompt.  This assembly contains helper classes that are generated during the
run.  It includes classes to improve the performance of calling some CLR
classes from Python as well as CLR classes generated to represent any
new-style Python classes you might create in your program.  This file is
intended to only be in-memory.  In the future it will only be written to
disk if you run in an advanced debugging mode.  Right now it is always
written out because I assume that anyone running IronPython-0.6 wants to be
in advanced debugging mode all the time.  A good tool for looking at this
file is ildasm which ships with the .NET SDK.

BTW - __main__.exe is also generated primarily for debugging and
understanding purposes.  It should not be generated in the future because
CPython doesn't create a corresponding __main__.pyc file.  In the future
there will be a IronPythonCompiler (hopefully with an easier to type name)
to generate a exe or dll statically from a Python script.

More information about the Ironpython-users mailing list