I wouldn't claim to know a specific "purpose" for IronPython but it certainly can be used to write applications, and it can be used for scripting within a larger .NET application.
Aside from anything else, it's a handy way of gently easing Python developers into the world of .NET. (Why not learn C# at the same time? Come on in, the water's lovely...)
The biggest benefit of IronPython is that it brings the worlds of Python and .NET very close together.
If you have libraries (assemblies) written in C# you can import those directly into IronPython and use them, like this:
import clr
clr.AddReferenceToFileAndPath('MyAssembly.dll')
import MyNamespace
c = MyNamespace.MyClass()
c.MyFunction()
This is very nice for reusing exisiting .NET code when scripting or even interactive use with the IronPython interpreter.
Ordinary CPython requires Python .NET to do the same or similar things. In my experience, Python .NET works most of the time, but not always and IronPython provides a much more polished experience in accessing .NET from Python.
IronPython will probably always lag the reference implementation of CPython in terms of standard library support etc., but in general the development is not that far behind, that it would hard to work with coming from a CPython background.
Lastly, there are a few substantial differences between CPython and IronPython, to which, one should pay attention. Example - garbage collection (bit me the other day...).
IronPython 也比 CPython 更容易扩展。您只需在 C++ 代码上添加一个小的 C++/CLI 包装器即可。 CPython 没有什么比这更简单的了。这就是我开始使用 IronPython 的原因,因为我厌倦了用 CPython 为我的 C++ 代码编写包装器。 Boost.Python、SWIG 等对我来说不起作用。
IronPython with WPF is the most productive way to design a GUI that I'm aware of. Almost all of the app pictured below is written in IronPython. Only very small parts are done in C# or C++/CLI for performance reasons.
Sure, you do miss some WPF/C# integration, but you gain much more on the productiveness side.
IronPython is also much easier to extend than CPython. You take your C++ code and just add a small C++/CLI wrapper on top of it. CPython has nothing which is as easy as this. That's the reason that I've started using IronPython, because I got tired of writing wrappers for my C++ code in CPython. Boost.Python, SWIG, and the like didn't work for me.
IronPython is just Yet Another Python Implementation. You can use it anywhere you would use any other Python implementation. (Modulo platform constraints, of course – obviously you can't use IronPython on a Java-only device.)
IronPython is just Yet Another .NET Compiler. You can use it anywhere you would use any other .NET language.
IronPython is More Than Just Yet Another Python Implementation. It's a Python implementation that gives you full access to any .NET library.
IronPython is More Than Just Yet Another .NET Compiler. It's a .NET compiler that gives you full access to any Python library.
IronPython is an embeddable scripting engine for any .NET app, library and framework.
I think the Iron family of languages is primarily for adding more flavours to the platform, allowing you to get into .NET using a language that you are familiar with. It lowers the bar a lot for getting new people with different backgrounds into .NET
Even though the syntax is Python, the implementation is still built on top of the CLR and the end product will not differ a lot if you decide to go for an IronPython project instead of say C#.
I've had some experience with IronPython and find it nice to work with (it helps of course that I really like the language). IronPython is now considered a first class citizen by Microsoft, and that is also the impression you get when using it. One downside to using it though is that it isn't as widely adopted as the two main languages, causing some issues when it comes to collaboration and maintaining a code base over time.
I found it particularly useful when doing a .NET port of a search algorithm that was first implemented in Python.
Regarding adding scripting abilities to your app, that is probably not the original intention with IronPython, but it has been done. The Umbraco CMS has (or at least had) the ability to create widgets using Python as a dynamic scripting language within their platform. A pretty neat feature to have.
You should go ahead and try it out.. It's always good to have more tools in the belt :)
We use it as an embedded language inside of our software. I had an article on my blog, but recently switched to a new system. You can find an archived version (with broken image links) here:
Our field engineers now use the embedded language to test things on the fly, our quality assurance people use it to create small scripts to test all features of the hardware, etc....
You use it to write Python code that runs on the .NET platform. It's good for anything that Python is good for.
The Python language is the Python language, no matter what. IronPython is an implementation of the runtime for that language - the support code that compiles your source, creates a virtual machine to execute the bytecode in the resulting .pyc file, communicates with the OS in order to put command line arguments into sys.argv, and all that other fun stuff. (Well, OK, the .NET platform itself does a lot of the work, too. :) )
My experience of IronPython is usage it as part of engine that can be changed after installation of base .Net application. With help of Python we have described really large set of business rules, that can be changed from two system installation. Partially IronPython was used as plugin language.
The difference from script language - that after compilation IronPython executed as CLR code.
First: IronPython is really more of a compiler than an interpreter in the strictest sense - it will be used to generate .NET Assemblies from your python source files. So yes, you can write apps and most anything the .NET Framework can do.
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. It doesn't solve the problem of concurrency, but .NET provides much more robust constructs for dealing with it. I think this is pretty niche honestly, but it is certainly there.
The python.org wiki page for IronPython lists a bunch of key differentiators as well:
You can write an app in it, you can use it as a scripting language in your app.
It's used for accessing existing Python libraries and, if needed, writing parts of your code in Python if a .NET languages doesn't seem well enough suited for that job.
您可以将它用于一些很酷的事情,例如在您的应用程序中拥有一个嵌入式 Web 服务器,该服务器可以使用可用的 Python Web 框架之一进行开发。与在应用程序中托管 ASP.NET Web 服务器相比,开发起来更加容易和顺利。例如,CherryPy 还附带了一个内置 Web 服务器,只需进行一些小修改即可与 IronPython 正常工作。
You can use it for cool things like having an embedded web server within your application which can be developed with one of the available Python web frameworks. It is much easier and smoother to develop for than hosting an ASP.NET web server within your application. CherryPy for example comes with a builtin web server as well that should work fine with IronPython with a few small modifications.
发布评论
评论(12)
两者之一或两者:)
我不会声称知道 IronPython 的具体“用途”,但它肯定可以用于编写应用程序,并且它可以用于编写脚本在较大的 .NET 应用程序中。
抛开其他事情不谈,它是一种让 Python 开发人员轻松进入 .NET 世界的便捷方法。 (为什么不同时学习C#呢?进来吧,水真可爱……)
Either or both :)
I wouldn't claim to know a specific "purpose" for IronPython but it certainly can be used to write applications, and it can be used for scripting within a larger .NET application.
Aside from anything else, it's a handy way of gently easing Python developers into the world of .NET. (Why not learn C# at the same time? Come on in, the water's lovely...)
IronPython 的最大好处是它将 Python 和 .NET 的世界紧密结合在一起。
如果您有用 C# 编写的库(程序集),您可以将它们直接导入 IronPython 并使用它们,如下所示:
这对于在编写脚本甚至与 IronPython 解释器交互使用时重用现有的 .NET 代码非常有用。
普通的 CPython 需要 Python .NET 来完成相同或相似的事情。根据我的经验,Python .NET 在大多数情况下都可以工作,但并非总是有效,IronPython 在从 Python 访问 .NET 方面提供了更加完美的体验。
在标准库支持等方面,IronPython 可能总是落后于 CPython 的参考实现,但总的来说,开发并没有落后太多,以至于来自 CPython 背景的人很难使用。
最后,CPython 和 IronPython 之间存在一些实质性的差异,人们应该为此付出代价注意力。示例 - 垃圾收集(前几天咬了我......)。
The biggest benefit of IronPython is that it brings the worlds of Python and .NET very close together.
If you have libraries (assemblies) written in C# you can import those directly into IronPython and use them, like this:
This is very nice for reusing exisiting .NET code when scripting or even interactive use with the IronPython interpreter.
Ordinary CPython requires Python .NET to do the same or similar things. In my experience, Python .NET works most of the time, but not always and IronPython provides a much more polished experience in accessing .NET from Python.
IronPython will probably always lag the reference implementation of CPython in terms of standard library support etc., but in general the development is not that far behind, that it would hard to work with coming from a CPython background.
Lastly, there are a few substantial differences between CPython and IronPython, to which, one should pay attention. Example - garbage collection (bit me the other day...).
据我所知,IronPython 与 WPF 是设计 GUI 的最高效的方法。下图所示的几乎所有应用程序都是用 IronPython 编写的。出于性能原因,只有非常小的部分是用 C# 或 C++/CLI 完成的。
当然,您确实错过了一些 WPF/C# 集成,但您在生产力方面获得了更多。
IronPython 也比 CPython 更容易扩展。您只需在 C++ 代码上添加一个小的 C++/CLI 包装器即可。 CPython 没有什么比这更简单的了。这就是我开始使用 IronPython 的原因,因为我厌倦了用 CPython 为我的 C++ 代码编写包装器。 Boost.Python、SWIG 等对我来说不起作用。
IronPython with WPF is the most productive way to design a GUI that I'm aware of. Almost all of the app pictured below is written in IronPython. Only very small parts are done in C# or C++/CLI for performance reasons.
Sure, you do miss some WPF/C# integration, but you gain much more on the productiveness side.
IronPython is also much easier to extend than CPython. You take your C++ code and just add a small C++/CLI wrapper on top of it. CPython has nothing which is as easy as this. That's the reason that I've started using IronPython, because I got tired of writing wrappers for my C++ code in CPython. Boost.Python, SWIG, and the like didn't work for me.
我认为 Iron 系列语言主要是为了向平台添加更多风格,允许您使用您熟悉的语言进入 .NET。它大大降低了不同背景的新人进入 .NET 的门槛。
尽管语法是 Python,但实现仍然构建在 CLR 之上,如果您决定使用 IronPython,最终产品不会有太大差异项目而不是说 C#。
我有一些使用 IronPython 的经验,并发现它很好用(当然,我真的很喜欢这门语言,这很有帮助)。 IronPython 现在被 Microsoft 视为一等公民,这也是您在使用它时得到的印象。但使用它的一个缺点是它不像两种主要语言那样被广泛采用,随着时间的推移,在协作和维护代码库方面会导致一些问题。
我发现它在对最初用 Python 实现的搜索算法进行 .NET 移植时特别有用。
关于向应用程序添加脚本功能,这可能不是 IronPython 的初衷,但它已经完成了。 Umbraco CMS 具有(或至少具有)在其平台内使用 Python 作为动态脚本语言来创建小部件的能力。这是一个非常简洁的功能。
你应该继续尝试一下.. 腰带上有更多工具总是好的:)
I think the Iron family of languages is primarily for adding more flavours to the platform, allowing you to get into .NET using a language that you are familiar with. It lowers the bar a lot for getting new people with different backgrounds into .NET
Even though the syntax is Python, the implementation is still built on top of the CLR and the end product will not differ a lot if you decide to go for an IronPython project instead of say C#.
I've had some experience with IronPython and find it nice to work with (it helps of course that I really like the language). IronPython is now considered a first class citizen by Microsoft, and that is also the impression you get when using it. One downside to using it though is that it isn't as widely adopted as the two main languages, causing some issues when it comes to collaboration and maintaining a code base over time.
I found it particularly useful when doing a .NET port of a search algorithm that was first implemented in Python.
Regarding adding scripting abilities to your app, that is probably not the original intention with IronPython, but it has been done. The Umbraco CMS has (or at least had) the ability to create widgets using Python as a dynamic scripting language within their platform. A pretty neat feature to have.
You should go ahead and try it out.. It's always good to have more tools in the belt :)
我们将其用作软件内部的嵌入式语言。
我的博客上有一篇文章,但最近切换到了新系统。您可以在这里找到存档版本(带有损坏的图像链接):
我们的现场工程师现在使用嵌入式语言来动态测试事物,
我们的质量保证人员使用它来创建小脚本来测试硬件的所有功能等......
希望这有帮助。
We use it as an embedded language inside of our software.
I had an article on my blog, but recently switched to a new system. You can find an archived version (with broken image links) here:
Our field engineers now use the embedded language to test things on the fly,
our quality assurance people use it to create small scripts to test all features of the hardware, etc....
Hope this helps.
您可以使用它来编写在 .NET 平台上运行的 Python 代码。它对 Python 擅长的任何事情都有好处。
无论如何,Python 语言就是 Python 语言。 IronPython 是该语言的运行时实现 - 支持代码,用于编译源代码、创建虚拟机以执行生成的 .pyc 文件中的字节码、与操作系统通信以放置命令将参数行放入 sys.argv 中,以及所有其他有趣的东西。 (好吧,.NET 平台本身也做了很多工作。:))
You use it to write Python code that runs on the .NET platform. It's good for anything that Python is good for.
The Python language is the Python language, no matter what. IronPython is an implementation of the runtime for that language - the support code that compiles your source, creates a virtual machine to execute the bytecode in the resulting .pyc file, communicates with the OS in order to put command line arguments into
sys.argv
, and all that other fun stuff. (Well, OK, the .NET platform itself does a lot of the work, too. :) )我对 IronPython 的体验是将其用作引擎的一部分,可以在安装基础 .Net 应用程序后进行更改。
在Python的帮助下,我们描述了非常大的业务规则集,可以通过两个系统安装来更改它们。部分使用 IronPython 作为插件语言。
与脚本语言的区别 - IronPython 编译后作为 CLR 代码执行。
My experience of IronPython is usage it as part of engine that can be changed after installation of base .Net application.
With help of Python we have described really large set of business rules, that can be changed from two system installation. Partially IronPython was used as plugin language.
The difference from script language - that after compilation IronPython executed as CLR code.
首先:从严格意义上讲,IronPython 实际上更像是一个编译器,而不是解释器 - 它将用于从 Python 源文件生成 .NET 程序集。所以,是的,您可以编写应用程序以及 .NET Framework 可以执行的大多数操作。
IronPython 最大的好处之一是它(实际上)没有 GIL - 这意味着如果您都在编写 Python 代码,并且它是多线程的 - 通常可以获得比 CPython 更好的性能,而无需跨越边界生成多个进程和 pickle 对象。它没有解决并发问题,但 .NET 提供了更健壮的构造来处理它。老实说,我认为这是相当小众的,但它确实存在。
IronPython 的 python.org wiki 页面也列出了一系列关键区别:
First: IronPython is really more of a compiler than an interpreter in the strictest sense - it will be used to generate .NET Assemblies from your python source files. So yes, you can write apps and most anything the .NET Framework can do.
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. It doesn't solve the problem of concurrency, but .NET provides much more robust constructs for dealing with it. I think this is pretty niche honestly, but it is certainly there.
The python.org wiki page for IronPython lists a bunch of key differentiators as well:
您可以在其中编写应用程序,也可以将其用作应用程序中的脚本语言。
它用于访问现有的 Python 库,如果需要,如果 .NET 语言似乎不太适合这项工作,则可以用 Python 编写部分代码。
You can write an app in it, you can use it as a scripting language in your app.
It's used for accessing existing Python libraries and, if needed, writing parts of your code in Python if a .NET languages doesn't seem well enough suited for that job.
我认为 Resolver Systems 使用 IronPython 构建了他们的产品。所以 IronPython 肯定有一些实际用途。
Enthought 还宣布他们将把 NumPy 移植到 IronPython 和 .Net。这肯定会扩大 IronPython 的吸引力。
I think Resolver Systems built their products with IronPython. So there is definitely some real-world use of IronPython.
Enthought also anounced that they will port NumPy to IronPython and .Net. This will certainly broaden the appeal of IronPython.
您可以将它用于一些很酷的事情,例如在您的应用程序中拥有一个嵌入式 Web 服务器,该服务器可以使用可用的 Python Web 框架之一进行开发。与在应用程序中托管 ASP.NET Web 服务器相比,开发起来更加容易和顺利。例如,CherryPy 还附带了一个内置 Web 服务器,只需进行一些小修改即可与 IronPython 正常工作。
You can use it for cool things like having an embedded web server within your application which can be developed with one of the available Python web frameworks. It is much easier and smoother to develop for than hosting an ASP.NET web server within your application. CherryPy for example comes with a builtin web server as well that should work fine with IronPython with a few small modifications.