Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., C#)

I am learning IronPython along wiht Python. I'm curious what kinds of tasks you tend to use IronPython to tackle more often than standard .NET languages.

Thanks for any example.

like image 527
Ricky Avatar asked Dec 16 '09 07:12

Ricky


People also ask

What is IronPython used for?

This means that IronPython can be used for client-side scripting in the browser. IronPython is a Python compiler. It compiles Python code to in memory bytecode before execution (which can be saved to disk, making binary only distributions possible).

Is IronPython good?

One of the largest benefits of IronPython is that it has (effectively) no GIL - meaning that if you are both writing Python code and it is multi-threaded - you can often get performance that is better than CPython without having to spawn multiple process and pickle objects across the boundaries.

What is the difference between IronPython and Python?

Python is Python, the only difference is that IronPython was designed to run on the CLR (. NET Framework), and as such, can inter-operate and consume . NET assemblies written in other . NET languages.


1 Answers

One example that is a perfect match for IronPython is when you want to include scriptability in your application. I have been working on systems where the user can interact with the whole application class model directly through the in-app python scripting layer and it allows for a great deal of flexibility for advanced users.

A tangible example is when you want to expose "hooks" in the application where the user can customize the business rules (say, do a custom broker fee calculation when a new trade is created in a trading system for instance).

Edit per request: here is a simple (mocked-upped) example. When a user creates a new trade in the system, the system checks if the following Python function is defined, and if present, the trade gets the result of the function as a fee added to it before it is committed to the database:

def calculate_broker_fee(trade):
    fee = 0.043 # default value
    if trade.exchange in ["SWX", "EURONEXT"] and \
        trade.instrument.instrument_type == "Bond":
        fee = trade.quantity*0.00234
    return fee
like image 85
Rickard Avatar answered Oct 19 '22 20:10

Rickard