Python - IronPython 困境
我开始学习Python,目前我非常喜欢它。但是,如果你能为我回答几个问题,这些问题一直困扰着我,而我找不到任何明确的答案:
Python 的 C 实现之间有什么关系(主要版本来自 python.org)和 IronPython,在语言兼容性方面?它是同一种语言吗?我通过学习一种语言,就能顺利地跨界到另一种语言吗?还是从 Java 到 JavaScript?
IronPython 库的当前状态如何?它落后于 CPython 库多少?我最感兴趣的是 numpy/scipy 和 f2py。 IronPython 可以使用它们吗?
从 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:
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 ?
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 ?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
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.
相同的语言(目前为 2.5 级别——据我所知,IronPython 还不是 2.6)。
标准库在今天的 IronPython 中处于良好状态,巨大的第三方扩展就像你提到的那些远离它的扩展。得益于 ironclad,但不是生产级别,因为
numpy
来自 IronPython(正如ironclad 的 0.5 版本号所证明的那样)
,&c)。scipy
庞大且庞大,充满了 C 编码和 Fortran 编码的扩展:我没有第一手经验,但我怀疑只有不到一半的人能够在任何实现下运行,更不用说完美运行了除了 CPython。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 或虚拟控制”;-)。
Same language (at 2.5 level for now -- IronPython's not 2.6 yet AFAIK).
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 asnumpy
is from IronPython (as witnessed by the 0.5 version number forironclad
, &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.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";-).
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.
对于语法来说,两者是相同的。但我们不能说它们是同一种语言。当您在Windows平台上进行开发时,IronPython可以有效地使用.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.