简体   繁体   English

Python 3.11 对 Cython 编译模块的影响

[英]Effect of Python 3.11 on Cython-compiled modules

I have a pure-Python module that compiles with Cython into .so , for performance.我有一个纯 Python 模块,它使用 Cython 编译成.so以提高性能。

The project currently uses Python 3.8 and everything works fine.该项目目前使用 Python 3.8,一切正常。

I've read CPython 3.11 comes with potentially great performance benefits , so I'm wondering the cost/benefit effort of upgrading.我读过 CPython 3.11 comes with potentially great performance benefits ,所以我想知道升级的成本/收益。

Do any of the CPython 3.11 optimizations translate to Cython-compiled code?是否有任何 CPython 3.11优化转换为 Cython 编译的代码? Which ones?哪个? How much?多少?

What is the expected overall effect of Cython on 3.11 relative to 3.8 code?相对于 3.8 代码,Cython 在 3.11 上的预期整体效果如何?

Basically none of it.基本上都没有。

  • Start-up applies to starting the interpreter (before you load any Cython modules)启动适用于启动解释器(在加载任何 Cython 模块之前)
  • "Cheaper, lazy Python frames" - Cython doesn't create frames (apart from when an exception is raised, and even then I doubt it applies) “更便宜、更懒惰的 Python 框架”——Cython 不创建框架(除了引发异常时,即使那样我也怀疑它是否适用)
  • "Adaptive interpreter" is for interpreted code. “自适应解释器”用于解释代码。 It specializes bytecode based on past results - so if an attribute lookup bytecode instruction in a certain function turns out to be looking up in a class, it assumes the same will apply next time.它根据过去的结果专门化字节码——所以如果某个函数中的属性查找字节码指令结果是在类中查找,它假定下次同样适用。 Since Cython doesn't use bytecode, these optimizations just don't apply.由于 Cython 不使用字节码,因此这些优化不适用。 (However, if you've applied static types correctly then Cython may be doing similar optimizations already) (但是,如果您正确应用了静态类型,那么 Cython 可能已经在进行类似的优化)

As ever, if you're really interested then you should measure it.一如既往,如果你真的感兴趣,那么你应该测量它。 But I wouldn't expect many benefits to Cython code但我不希望 Cython 代码有很多好处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM