ctypes for static libraries?

后端 未结 2 1932
情话喂你
情话喂你 2021-01-11 09:51

I\'m attempting to write a Python wrapper for poker-eval, a c static library. All the documentation I can find on ctypes indicates that it works on shared/dynamic libraries.

相关标签:
2条回答
  • 2021-01-11 10:16

    I can't say for sure there are no modules out there, but the advantages of dynamic libraries (uses less space, can update without recompiling dependent programs) are such that you're probably better off doing just that.

    0 讨论(0)
  • 2021-01-11 10:31

    The choice is really up to you. If you have the ability to recompile the library as a shared object, I would suggest that, because it will minimize the non-python code you have to maintain. Otherwise, you'll want to build a python extension module that links to the static library and wraps the functions it exposes.

    You mentioned Cython; here's the relevant manual page if you go that route:

    http://docs.cython.org/src/tutorial/clibraries.html

    There's also SWIG and Pyrex.

    0 讨论(0)
提交回复
热议问题