Python 或 IronPython

发布于 2024-07-14 14:39:02 字数 185 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

深海夜未眠 2024-07-21 14:39:02

有许多重要的区别:

  1. 与其他 .NET 语言的互操作性。 例如,您可以从 IronPython 应用程序使用其他 .NET 库,或者从 C# 应用程序使用 IronPython。 随着 .NET 4.0 中对动态类型的更多支持,这种互操作性正在增强。 有关详细信息,请参阅 这些 两个< /a> 在 PDC 2008 上的演示。
  2. 由于缺少 GIL,因此提供了更好的并发/多核支持。 (请注意,GIL 不会禁止单核计算机上的线程处理——它只会限制多核计算机上的性能。)
  3. 使用 Python C 扩展的能力有限。 Ironclad 项目正在制作在改进这一点方面取得了重大进展——他们几乎已经让 Numpy 工作了!
  4. 跨平台支持较少; 基本上,您已经有了 CLR 和 Mono。 不过,Mono 令人印象深刻,并且可以在许多平台上运行——而且他们有一个 Silverlight 的实现,称为
  5. 有关性能改进的报告,尽管我没有仔细研究过这一点。
  6. 功能滞后:由于 CPython 是参考 Python 实现,因此它具有“最新和最好的”Python 功能,而 IronPython 必然落后。 许多人并不认为这是一个问题。

There are a number of important differences:

  1. Interoperability with other .NET languages. You can use other .NET libraries from an IronPython application, or use IronPython from a C# application, for example. This interoperability is increasing, with a movement toward greater support for dynamic types in .NET 4.0. For a lot of detail on this, see these two presentations at PDC 2008.
  2. Better concurrency/multi-core support, due to lack of a GIL. (Note that the GIL doesn't inhibit threading on a single-core machine---it only limits performance on multi-core machines.)
  3. Limited ability to consume Python C extensions. The Ironclad project is making significant strides toward improving this---they've nearly gotten Numpy working!
  4. Less cross-platform support; basically, you've got the CLR and Mono. Mono is impressive, though, and runs on many platforms---and they've got an implementation of Silverlight, called Moonlight.
  5. Reports of improved performance, although I have not looked into this carefully.
  6. Feature lag: since CPython is the reference Python implementation, it has the "latest and greatest" Python features, whereas IronPython necessarily lags behind. Many people do not find this to be a problem.
゛时过境迁 2024-07-21 14:39:02

编写代码的方式存在一些细微的差异,但最大的差异在于可用的库。

使用 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.

花海 2024-07-21 14:39:02

嗯,一般来说速度更快。

无法使用模块,并且只有库的一个子集。

以下是差异列表。

Well, it's generally faster.

Can't use modules, and only has a subset of the library.

Here's a list of differences.

七禾 2024-07-21 14:39:02

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.

孤独患者 2024-07-21 14:39:02

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.

枕头说它不想醒 2024-07-21 14:39:02

专业版:您可以在浏览器中运行 IronPython< /a> 如果安装了 SilverLight。

Pro: You can run IronPython in a browser if SilverLight is installed.

这个俗人 2024-07-21 14:39:02

它还取决于您是否希望您的代码在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文