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.
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).
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With