Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (47.6k points)

What would be the quickest way to construct a Python binding to a C or C++ library?

(I am using Windows if this matters.)

1 Answer

0 votes
by (106k points)

You can use Boost.Python that helps you in calling C/C++ from Python:-

So, the Boost Python Library is a framework for interfacing Python and C++.  This library is used for quickly and seamlessly exposure of C++ classes functions and objects to Python, and vice-versa, using no special tools -- just your C++ compiler. 

Another thing in Python we have ctypes which is a part of the standard library and therefore is more stable and widely available.

When you use ctypes, you need to satisfy any compile-time dependency on python, and your binding will work on any python that has ctypes, not just the one it was compiled against.

Related questions

0 votes
1 answer
asked Dec 4, 2020 in Python by laddulakshana (12.7k points)
0 votes
1 answer
asked Aug 1, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
asked Dec 23, 2020 in Python by ashely (50.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...