Python - IronPython 困境

发布于 2024-08-04 12:22:05 字数 412 浏览 5 评论 0原文

我开始学习Python,目前我非常喜欢它。但是,如果你能为我回答几个问题,这些问题一直困扰着我,而我找不到任何明确的答案:

  1. Python 的 C 实现之间有什么关系(主要版本来自 python.org)和 IronPython,在语言兼容性方面?它是同一种语言吗?我通过学习一种语言,就能顺利地跨界到另一种语言吗?还是从 Java 到 JavaScript?

  2. IronPython 库的当前状态如何?它落后于 CPython 库多少?我最感兴趣的是 numpy/scipy 和 f2py。 IronPython 可以使用它们吗?

  3. 从 Python 访问 VB 以及反向访问 VB 的最佳方式是什么(准确地说,将一些 Python 库连接到 Excel 的 VBA)?

I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them:

  1. What is the relationship between Python's C implementation (main version from python.org) and IronPython, in terms of language compatibility ? Is it the same language, and do I by learning one, will be able to smoothly cross to another, or is it Java to JavaScript ?

  2. What is the current status to IronPython's libraries ? How much does it lags behind CPython libraries ? I'm mostly interested in numpy/scipy and f2py. Are they available to IronPython ?

  3. What would be the best way to access VB from Python and the other way back (connecting some python libraries to Excel's VBA, to be exact) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

表情可笑 2024-08-11 12:22:05

1) IronPython 和 CPython 共享几乎相同的语言语法。它们之间的差别很小。过渡应该是微不足道的。

2) IronPython 中的库与 CPython 有很大不同。 Python 库有点落后 - 很多 CPython 可访问的库(目前)在 IronPython 下无法工作。然而,IronPython 可以干净、直接地访问整个 .NET Framework,这意味着它拥有本机可访问的最广泛的库之一,因此在许多方面,它远远领先于 CPython。一些 numpy/scipy 库在 IronPython 中不起作用,但由于 .NET 实现,某些功能不是必需的,因为 perf.特点不同。

3) 如果您从 VBA 进行访问,则使用 IronPython 访问 Excel VBA 会更容易。如果您尝试自动化 Excel,IronPython 仍然更容易,因为您可以访问 Execl 主互操作程序集,并且可以使用与 C# 和 VB.NET 相同的库直接实现自动化。

1) IronPython and CPython share nearly identical language syntax. There is very little difference between them. Transitioning should be trivial.

2) The libraries in IronPython are very different than CPython. The Python libraries are a fair bit behind - quite a few of the CPython-accessible libraries will not work (currently) under IronPython. However, IronPython has clean, direct access to the entire .NET Framework, which means that it has one of the most extensive libraries natively accessible to it, so in many ways, it's far ahead of CPython. Some of the numpy/scipy libraries do not work in IronPython, but due to the .NET implementation, some of the functionality is not necessary, since the perf. characteristics are different.

3) Accessing Excel VBA is going to be easier using IronPython, if you're doing it from VBA. If you're trying to automate excel, IronPython is still easier, since you have access to the Execl Primary Interop Assemblies, and can directly automate it using the same libraries as C# and VB.NET.

清风无影 2024-08-11 12:22:05

两者之间有什么关系
Python 的 C 实现(主要
来自 python.org 的版本)和
IronPython,就语言而言
兼容性 ?是一样的吗
语言,我通过学习一门语言,
就能顺利穿越到
另一个,或者是 Java 到 JavaScript?

相同的语言(目前为 2.5 级别——据我所知,IronPython 还不是 2.6)。

当前状态如何
IronPython 的库?多少钱
它落后于 CPython 库吗?我是
主要对 numpy/scipy 感兴趣并且
f2py。 IronPython 是否可以使用它们

标准库在今天的 IronPython 中处于良好状态,巨大的第三方扩展就像你提到的那些远离它的扩展。得益于 ironclad,但不是生产级别,因为 numpy 来自 IronPython(正如 ironclad 的 0.5 版本号所证明的那样),&c)。 scipy 庞大且庞大,充满了 C 编码和 Fortran 编码的扩展:我没有第一手经验,但我怀疑只有不到一半的人能够在任何实现下运行,更不用说完美运行了除了 CPython。

最好的访问方式是什么
来自 Python 的 VB 以及相反的方式
(将一些Python库连接到
准确地说,是 Excel 的 VBA)?

IronPython 应该通过 .NET 方法使其变得更容易,但通过 win32all 中的 COM 实现,CPython 还没有那么远

最后但并非最不重要的一点是,一定要看看IronPython in Action这本书——就像我每次说的那样我推荐它,我有偏见(因为我曾担任过它的技术审阅者,并且与一位作者有友谊),但我认为它客观上是针对 .NET 开发人员的 Python 最佳介绍,同时也是针对 .NET 的最佳介绍。 Python 爱好者。

如果您需要 scipy 的全部功能(哇,但那是一些“文艺复兴时期的人”计算科学家!-),CPython 确实是当今唯一真正的选择。我确信其他大型扩展(例如 PyQt 或 Mayavi)也处于类似的状态。然而,对于与当今 Windows 的深度集成,我认为 IronPython 可能具有优势。对于通用用途,CPython 可能更好(尤其是由于 2.6 中的许多新功能),除非您真的热衷于在单个进程中充分使用多个内核,其中IronPython(无 GIL)的情况可能会再次证明是有利的。

不管怎样(甚至在 JVM 上通过 Jython,或者在特殊环境中通过 PyPy)Python 无疑是一门很棒的语言,无论您为给定应用程序选择什么实现!-)请注意,您不需要坚持一个实现(尽管您可能应该选择一个版本 - 2.5 以获得与 IronPython、Jython、Google App Engine 等的最大兼容性;2.6 如果您不关心任何部署选项,除了“我自己的机器上的 CPython 或虚拟控制”;-)。

What is the relationship between
Python's C implementation (main
version from python.org) and
IronPython, in terms of language
compatibility ? Is it the same
language, and do I by learning one,
will be able to smoothly cross to
another, or is it Java to JavaScript ?

Same language (at 2.5 level for now -- IronPython's not 2.6 yet AFAIK).

What is the current status to
IronPython's libraries ? How much does
it lags behind CPython libraries ? I'm
mostly interested in numpy/scipy and
f2py. Are they available to IronPython
?

Standard libraries are in a great state in today's IronPython, huge third-party extensions like the ones you mention far from it. numpy's starting to get feasible thanks to ironclad, but not production-level as numpy is from IronPython (as witnessed by the 0.5 version number for ironclad, &c). scipy is huge and sprawling and chock full of C-coded and Fortran-coded extensions: I have no first-hand experience but I suspect less than half will even run, much less run flawlessly, under any implementation except CPython.

What would be the best way to access
VB from Python and the other way back
(connecting some python libraries to
Excel's VBA, to be exact) ?

IronPython should make it easier via .NET approaches, but CPython is not that far via COM implementation in win32all.

Last but not least, by all means check out the book IronPython in Action -- as I say every time I recommend it, I'm biased (by having been a tech reviewer for it AND by friendship with one author) but I think it's objectively the best intro to Python for .NET developers AND at the same time the best intro to .NET for Pythonistas.

If you need all of scipy (WOW, but that's some "Renaissance Man" computational scientist!-), CPython is really the only real option today. I'm sure other large extensions (PyQt, say, or Mayavi) are in a similar state. For deep integration to today's Windows, however, I think IronPython may have an edge. For general-purpose uses, CPython may be better (esp. thanks to the many new features in 2.6), unless you're really keen to use many cores to the hilt within a single process, in which case IronPython (which is GIL-less) may prove advantageous again.

One way or another (or even on the JVM via Jython, or in peculiar environments via PyPy) Python is surely an awesome language, whatever implementation(s) you pick for a given application!-) Note that you don't need to stick with ONE implementation (though you should probably pick one VERSION -- 2.5 for maximal compatibility with IronPython, Jython, Google App Engine, etc; 2.6 if you don't care about any deployment options except "CPython on a machine under my own sole or virtual control";-).

鸢与 2024-08-11 12:22:05
  1. 当前版本的 IronPython 版本 2.0.2 支持 Python 2.5 语法。下一个版本 2.6 预计在下个月左右的某个时间发布(尽管我不确定团队是否已经设定了硬性发布日期;这里是 beta),它们将支持 Python 2.6 语法。因此,更少的 Java 到 JavaScript,更多的 Java 到 J# :-)
  2. 所有用 Python 编写的库都可以完美地工作。用C写的问题比较多;有一个名为 Ironclad 的开源项目(完全披露:由我的公司开发和支持) ,目前版本为 0.8.5,它很好地支持 numpy,但没有涵盖所有 scipy。我认为我们没有用 f2py 测试过它。 (下面 Alex Martelli 提到的 Ironclad 版本已经有一年多了,请避免使用那个版本!)
  3. 从 IronPython 调用常规 VB.NET 非常简单——您可以非常轻松地实例化 .NET 类并调用方法(静态或实例) 。调用现有的 VBA 代码可能会比较棘手;有一些名为 PyinexXLW 您可能想看看。或者,如果您想要一个可以用 Python 编码的电子表格,那么总有 Resolver One (我公司的另一张...:-)
  1. IronPython version 2.0.2, the current release, supports Python 2.5 syntax. With the next release, 2.6, which is expected sometime over the next month or so (though I'm not sure the team have set a hard release date; here's the beta), they will support Python 2.6 syntax. So, less Java to JavaScript and more Java to J# :-)
  2. All of the libraries that are themselves written in Python work pretty much perfectly. The ones that are written in C are more problematic; there is an open source project called Ironclad (full disclosure: developed and supported by my company), currently at version 0.8.5, which supports numpy pretty well but doesn't cover all of scipy. I don't think we've tested it with f2py. (The version of Ironclad mentioned below by Alex Martelli is over a year old, please avoid that one!)
  3. Calling regular VB.NET from IronPython is pretty easy -- you can instantiate .NET classes and call methods (static or instance) really easily. Calling existing VBA code might be trickier; there are open source projects called Pyinex and XLW that you might want to take a look at. Alternatively, if you want a spreadsheet you can code in Python, then there's always Resolver One (another one from my company... :-)
迷你仙 2024-08-11 12:22:05

1)CPython和IronPython实现的语言是相同的,或者最多相差一两个版本。这与 Java 和 Javascript 的情况完全不同,这两种完全不同的语言由于一些愚蠢的营销决策而被赋予了相似的名称。

2)必须仔细评估用 C 实现的第三方库(例如 numpy)。 IronPython 有一个执行 C 扩展的工具(我忘记了名字),但是有很多陷阱,所以你需要咨询每个库的维护者

3) 我不知道。

1) The language implemented by CPython and IronPython are the same, or at most a version or two apart. This is nothing like the situation with Java and Javascript, which are two completely different languages given similar names by some bone-headed marketing decision.

2) 3rd-party libraries implemented in C (such as numpy) will have to be evaluated carefully. IronPython has a facility to execute C extensions (I forget the name), but there are many pitfalls, so you need to check with each library's maintainer

3) I have no idea.

天赋异禀 2024-08-11 12:22:05
  1. CPython是由C语言针对相应平台实现的,例如Windows、Linux或Unix; IronPython是由C#和Windows .Net Framework实现的,因此它只能运行在带有.Net Framework的Windows平台上。
    对于语法来说,两者是相同的。但我们不能说它们是同一种语言。当您在Windows平台上进行开发时,IronPython可以有效地使用.Net Framework。
  2. 到目前为止,2009 年 7 月 21 日——我们最新的 IronPython 稳定版本 IronPython 2.0.2 发布了。您可以参考http://www.codeplex.com/Wiki/View。 aspx?ProjectName=IronPython.
  3. 您可以通过 IronPython 使用 .Net Framework 功能访问 VB。所以,如果你想掌握IronPython,你最好多学习.Net Framework。
  1. CPython is implemented by C for corresponding platform, such as Windows, Linux or Unix; IronPython is implemented by C# and Windows .Net Framework, so it can only run on Windows Platform with .Net Framework.
    For gramma, both are same. But we cannot say they are one same language. IronPython can use .Net Framework essily when you develop on windows platform.
  2. By far, July 21, 2009 - IronPython 2.0.2, our latest stable release of IronPython, was released. you can refer to http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython.
  3. You can access VB with .Net Framework function by IronPython. So, if you want to master IronPython, you'd better learn more .Net Framework.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文