Alternatives of fused type in cython

半城伤御伤魂 提交于 2019-12-06 14:17:52

Ignoring ali_m's perfectly valid comment about whether you've actually measured your performance issues...

http://docs.cython.org/src/userguide/fusedtypes.html#selecting-specializations

"For a cdef or cpdef function called from Cython this means that the specialization is figured out at compile time. For def functions the arguments are typechecked at runtime, and a best-effort approach is performed to figure out which specialization is needed."

Essentially, if you're calling from Cython there should be no issue - separate functions are generated and used without overhead. If you're calling from Python it obviously has to stop and think about which one to call.

But measure your performance before worrying about it! (And read the manual, which answers your question quite clearly.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!