ctypes for static libraries?
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. Is there a ctypes for static libraries?
I know about cython, but should I use that or recompile the poker-eva开发者_如何学Gol into a dynamic library so that I can use ctypes?
Thanks,
Mike
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.
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.
精彩评论