Stefan Sonnenberg-Carstens, 06.01.2011 07:08:
Am 05.01.2011 23:44, schrieb Rohit Coder:
I am just asking. In future I may need to import any C++ library, not a
Crypto, but some other. Is it possible?
Yes.
There are at least five possible ways:

- Handcode the interface and glue code (http://docs.python.org/extending)
- use SWIG to autogenerate (mostly) the interface (http://www.swig.org)
- using BOOST's python interface
(http://www.boost.org/doc/libs/1_45_0/libs/python/doc/index.html)

None of these is worth recommending. Too much work, too hard to build a good interface with them and simply too slow for the invested effort.

Their main drawback is that they distract you from designing wrappers and require you to think about lots of C/C++ problems.


- using ctypes module for runtime interaction (like and use it a _lot_,
very cool for rapid prototyping :-)
http://docs.python.org/library/ctypes.html)
- cython (different approach, implements a python subset, http://cython.org)

IMHO, these are the two ways to do it nowadays. Cython wrappers are obviously much faster than anything you could ever write in ctypes, but both are similarly easy to use and allow users to focus on good wrapper design.

Stefan

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to