Easiest way to access C module in Python

Rob Gaddi rgaddi at highlandtechnology.invalid
Tue Nov 7 12:52:02 EST 2017


On 11/06/2017 05:59 PM, Grant Edwards wrote:
> On 2017-11-06, John Pote <johnpote at jptechnical.co.uk> wrote:
> 
>> I have successfully used Python to perform unit and integration tests in
>> the past and I'd like to do the same for some C modules I'm working with
>> at work. There seem to be a number of ways of doing this but being busy
>> at work and home I looking for the approach with the least learning curve.
> 
> When I want to test C modules (usually destined for an embedded
> system) using a Python framework, I use ctypes.
> 
> https://docs.python.org/3/library/ctypes.html
> 

I'll second ctypes.  It's pretty straightforward and I've made it do 
some very heavy lifting over the years.  Cython is definitely more work. 
  SWIG makes sense if you've got a huge number of interfaces you're trying
to map and need to automate the process, but if you've got south of 20 
I'd just do it natively with ctypes.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.



More information about the Python-list mailing list