November 2018
Intermediate to advanced
310 pages
7h 54m
English
We will now give a brief overview of the Ctypes module from the Python Standard Library. Ctypes is used for calling functions from the Linux .so (shared object) or Windows. DLL (Dynamically Linked Library) pre-compiled binaries. This will allow us to break out of the world of pure Python and interface with libraries and code that have been written in compiled languages, notably C and C++—it just so happens that Nvidia only provides such pre-compiled binaries for interfacing with our CUDA device, so if we want to sidestep PyCUDA, we will have to use Ctypes.
Let's start with a very basic example: we will show you how to call printf directly from Ctypes. Open up an instance of IPython and type import ctypes ...
Read now
Unlock full access