Analyzing performance
We’ve now seen two ways to make our GPU code available to Python. It is clear that ctypes is very straightforward, despite that awkward way of defining the functions that will be used. Creating an extension, on the other hand, offers a very clear interface to the end user even though it is a little more laborious.
However, it is not only style that counts here; it is also clear that our extension implementation that did not use numpy arrays involved extensive data copying. The question is: how much does that affect the overall performance?

Figure 9.2: Execution time for each type of Python integration
Quick tip: Need to see a high-resolution version of this image? Open this book in the next-gen Packt Reader or view it in the PDF/ePub copy.
The next-gen Packt Reader and a free PDF/ePub copy of this book are included with your purchase. Scan the QR code OR visit packtpub.com/unlock, then use the search bar to find this book...