Go和Cython的区别 [英] Differences between Go and Cython
问题描述
Cython isn这不是传统意义上的语言。它是一个构建Python扩展的预处理器,它采用类似Python的语法(实际上它们力求完全兼容Python)并生成C代码(使用Python C API)。这样做,他们可以包括一些特殊情况优化,但是当您添加并入C代码中的Cython特定静态类型信息时,会带来真正的好处,绕过这些操作的Python运行时间并导致高速加速。
Go是一种编译的编程语言。在Go中可以做的第一件事就是生成一个不包含Python运行时的可执行文件/启动一个Python解释器 - 这在Cython中是不可能的。 (在技术上可能不是不可能 - 但如果你不使用Python,那么使用Cython确实没有意义)。由于Cython只生成C,所以在注释中大部分问题并不适用 - 您可以使用任何C调试器(尽管事实是Python扩展会使事情变得复杂一些)。
Today a great friend of mine asked me what are the main differences between the newest Go language and Cython, which is a set of C-extensions for Python. I don't have much knowledge on Python, can anyone tell me why Go is better/worse than Cython?
Cython isn't really a language in the conventional sense. It is a preprocessor for building Python extensions that takes Python-like syntax (actually they strive for full Python compatibility) and produces C code (using the Python C API). Doing this they are able to include some special case optimisations, but the real benefits come when you add Cython specific static type information which is incorporated into the C code, bypassing the Python runtime for those operations and resulting in a high speed up.
Go is a compiled programming language. The first thing that can be done in Go is producing an executable that doesn't include the Python runtime/start a Python interpreter - this is impossible in Cython. (May not be technically impossible - but there is really no point to use Cython if you are not working with Python). Since Cython just produces C most of your questions in the comment don't really apply - you can use any C debugger (although the fact that's a Python extension makes things a bit more complicated).
这篇关于Go和Cython的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!