Book Image

Daniel Arbuckle's Mastering Python

By : Daniel Arbuckle
Book Image

Daniel Arbuckle's Mastering Python

By: Daniel Arbuckle

Overview of this book

Daniel Arbuckle's Mastering Python covers the basics of operating in a Python development environment, before moving on to more advanced topics. Daniel presents you with real-world solutions to Python 3.6 and advanced-level concepts, such as reactive programming, microservices, ctypes, and Cython tools. You don't need to be familiar with the Python language to use this book, as Daniel starts with a Python primer. Throughout, Daniel highlights the major aspects of managing your Python development environment, shows you how to handle parallel computation, and helps you to master asynchronous I/O with Python 3.6 to improve performance. Finally, Daniel will teach you the secrets of metaprogramming and unit testing in Python, helping you acquire the perfect skillset to be a Python expert. Daniel will get you up to speed on everything from basic programming practices to high-end tools and techniques, things that will help set you apart as a successful Python programmer.
Table of Contents (13 chapters)

Interfacing with C code using Cython

In this section, we're going to look at a third-party tool called Cython, which is another tool for bridging the gap between Python and the software that has been compiled into machine code.

If we have a situation where we want to implement part of our project in compiled code, we could do this by creating a dynamic library containing the code and calling to it with ctypes; however, that's a roundabout way to get where we want to go. We'd end up writing a lot of code twice: once for the sake of our compiler and then again to tell ctypes about details such as function signatures and data structures.

Now this is inefficient and violates one of the most important principles of programming—don't repeat yourself. There's a tool that's better suited to this situation, as you may have surely guessed, and that tool...