Python 或 IronPython
IronPython 如何与 python.org 中的 Python 默认 Windows 实现相媲美? 如果我正在学习 Python,我是否会通过 IronPython 学习一门略有不同的语言?如果没有哪些库,我会做什么?
或者,IronPython(不包括 .NET IL 编译类)是否有任何优点可以使其成为更具吸引力的选择?
How does IronPython stack up to the default Windows implementation of Python from python.org? If I am learning Python, will I be learning a subtley different language with IronPython, and what libraries would I be doing without?
Are there, alternatively, any pros to IronPython (not including .NET IL compiled classes) that would make it more attractive an option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
有许多重要的区别:
There are a number of important differences:
编写代码的方式存在一些细微的差异,但最大的差异在于可用的库。
使用 IronPython,您可以获得所有可用的 .Net 库,但代价是一些我认为尚未移植到 .Net VM 的“正常”Python 库。
基本上,您应该期望语法和惯用语是相同的,但是如果您尝试将为 IronPython 编写的脚本提供给“常规”Python 解释器,则该脚本将不会运行。 相反的可能性可能更大,但我认为你也会发现差异。
There are some subtle differences in how you write your code, but the biggest difference is in the libraries you have available.
With IronPython, you have all the .Net libraries available, but at the expense of some of the "normal" python libraries that haven't been ported to the .Net VM I think.
Basically, you should expect the syntax and the idioms to be the same, but a script written for IronPython wont run if you try giving it to the "regular" Python interpreter. The other way around is probably more likely, but there too you will find differences I think.
嗯,一般来说速度更快。
无法使用模块,并且只有库的一个子集。
以下是差异列表。
Well, it's generally faster.
Can't use modules, and only has a subset of the library.
Here's a list of differences.
Python 就是 Python,唯一的区别是 IronPython 被设计为在 CLR(.NET Framework)上运行,因此可以互操作和使用用其他 .NET 语言编写的 .NET 程序集。 因此,如果您的平台是 Windows 并且您也使用 .NET 或者您的公司使用 .NET,那么应该考虑 IronPython。
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. So if your platform is Windows and you also use .NET or your company does then should consider IronPython.
IronPython 的优点之一是,与 CPython 不同,IronPython 不使用全局解释器锁,从而使线程更加有效。
在标准 Python 实现中,线程在每次对象访问时获取 GIL。 这限制了并行执行,如果您希望充分利用多个 CPU,这一点尤其重要。
One of the pros of IronPython is that, unlike CPython, IronPython doesn't use the Global Interpreter Lock, thus making threading more effective.
In the standard Python implementation, threads grab the GIL on each object access. This limits parallel execution, which matters especially if you expect to fully utilize multiple CPUs.
专业版:您可以在浏览器中运行 IronPython< /a> 如果安装了 SilverLight。
Pro: You can run IronPython in a browser if SilverLight is installed.
它还取决于您是否希望您的代码在 Linux 上运行。 不知道 IronPython 是否可以在 Windows 平台以外的任何平台上运行。
It also depends on whether you want your code to work on Linux. Dunno if IronPython will work on anything beside windows platforms.