PyOpenGL-accelerate 到底是什么?

What exactly is PyOpenGL-accelerate?

标题是这里的主要问题。我的计算机上有一些 PyOpenGL 代码 运行,运行 有点慢。我意识到我没有安装 PyOpenGL-accelerate。这根本没有改变速度,但是大多数带有 Python OpenGL 绑定的教程建议应该安装 PyOpenGL-accelerate。

这个模块到底是做什么的?

来自documentation

This set of C (Cython) extensions provides acceleration of common operations for slow points in PyOpenGL 3.x. For code which uses large arrays extensively speed-up is around 10% compared to unaccelerated code.

如果您想准确了解定义了哪些优化,您可以深入研究代码,但 OpenGL 通常是围绕令人惊讶的粗略优化构建的,以考虑不同的硬件 - 我想扩展到 运行还有口译员。

首先请注意,PyOpenGL-accelerate 不是灵丹妙药。因此,如果您的应用程序优化不佳,那么 PyOpenGL-accelerate 不会为您带来太多额外的性能。

话虽这么说。 PyOpenGL-accelerate 由 Cython 加速器模块组成,这些模块试图加速 PyOpenGL 3.x 的各个方面。因此,如果您使用 glBegin()glEnd() 进行绘图,那么您将不会从中获得任何性能。

那么Cython加速器模块是什么?

These modules are completely self-contained, and are created solely to run faster than the equivalent pure Python code runs in CPython. Ideally, accelerator modules will always have a pure Python equivalent to use as a fallback if the accelerated version isn’t available on a given system. The CPython standard library makes extensive use of accelerator modules.

Python – Binary Extensions

通俗地说。 Cython 可以说是 Python 和 C 的混合体。目标是优化和执行速度。

关于 PyOpenGL-accelerate 这意味着 PyOpenGL 提供了各种帮助程序 类。而是以提供更高性能的方式实施。