IronPython
By the IronPython project
NET intermediate language rather than the bytecode used by the reference CPython interpreter. NET Dynamic Language Runtime.
Definition
IronPython is an implementation of the Python language built to run on the .NET Common Language Runtime, compiling Python source into .NET intermediate language rather than the bytecode used by the reference CPython interpreter. It gives Python code direct access to .NET classes and assemblies, and lets .NET applications embed Python as a dynamic scripting layer using the .NET Dynamic Language Runtime.
Overview
IronPython was created to let Python code operate as a first-class citizen inside the .NET platform, at a time when Microsoft's ecosystem had no native dynamic scripting language of comparable expressiveness. Instead of running as a separate interpreter that .NET code has to invoke through a subprocess or interop layer, IronPython compiles Python modules into .NET intermediate language, so a Python script can instantiate a C# class, call its methods, and hand objects back to .NET code within the same call stack and garbage-collected heap. Under the hood, IronPython is built on Microsoft's Dynamic Language Runtime, a set of services layered on top of the CLR specifically to support dynamically typed languages like Python, Ruby, and JavaScript variants. The DLR handles call-site caching and dynamic dispatch so that Python's duck typing and flexible attribute access can be resolved efficiently at runtime instead of requiring static type declarations, while the CLR's own JIT compiler optimizes the resulting intermediate language during execution. Within the family of alternative Python runtimes, IronPython is the .NET counterpart to Jython's JVM implementation, applying the same conceptual strategy, compiling to a managed runtime's intermediate representation, to a different platform. It differs from CPython in the same fundamental way Jython does: it cannot load CPython's compiled C extension modules, because the CLR provides no equivalent binary interface, which excludes much of the C-accelerated scientific Python ecosystem. In practice, IronPython is used to add scripting capability to .NET desktop applications, game engines, and enterprise tools, letting end users or administrators write automation scripts in Python against an application's exposed .NET object model. It has also been used inside Windows-based test automation and DevOps tooling where a team wants Python's syntax but needs tight, in-process integration with existing C# or VB.NET libraries. The practical trade-off mirrors Jython's: teams gain seamless two-way interoperability with .NET but give up compatibility with CPython's C extensions and, at times, lag behind the newest Python language releases. Projects that depend on packages with compiled C cores, or that need the latest Python syntax, are better served by CPython, reserving IronPython for cases where in-process .NET interoperability is the deciding requirement. A related consideration is tooling maturity: because IronPython has a smaller contributor base than either CPython or the .NET languages it interoperates with, editor support, debugging integration, and third-party package availability can lag behind what developers expect from a mainstream language, which is worth evaluating before committing a larger project to it.
Key Features
- Compiles Python source into .NET intermediate language for execution
- Runs on Microsoft's Dynamic Language Runtime built atop the CLR
- Allows Python code to directly call .NET assemblies and classes
- Lets .NET applications embed Python as an in-process scripting engine
- Shares the CLR garbage collector and JIT optimizer with C# code
- Supports interactive Python console sessions inside .NET hosts
- Provides two-way object passing between Python and .NET code
- Distributed as an open-source project independent of CPython