CLS Compilation of IronPython

In IronPython (and other Dynamic Language Runtime languages) Python classes are not static .NET types.

There are various reasons for this. .NET classes can't be garbage collected (assemblies can't be unloaded - unless you load them in another AppDomain and unload the whole AppDomain). Additionally dynamic languages typically allow you to add and remove members at runtime and in Python you can even change the base classes at runtime. For instances of Python classes we can also change the class at runtime, not usually recommended but possible...

This means that normally a Python class can't be a static .NET type, instead Python classes are .NET objects (instances of their metaclass - for new style classes without a custom metaclass that means 'PythonType').

This isn't without problems - in order to apply .NET attributes you basically need a sttic type. This leaves a hole in the interoperation between Common Language Runtime features and dynamic languages, and means their are various there are various things you can't do from IronPython and have to resort to C#. There is more to it than this summary, and different ways for this to be resolved - by both the DLR and the CLR teams at Microsoft.

Shri Borde has a blog entry explaining some of the issues and possibilities:

Comments

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

Should Python Projects Support IronPython and Jython?

Further Adventures of the Debugger