22.1. "I Am Lost at C"
So far in this book, we've been using Python as it comes out of the box. We have used interfaces to services outside Python, and we've coded extensions as Python modules. But we haven't added any external services beyond the built-in set. For many users, this makes perfect sense: such standalone programming is one of the main ways people apply Python. As we've seen, Python comes with batteries includedinterfaces to system tools, Internet protocols, GUIs, filesystems, and much more, are already available.
But for many systems, Python's ability to integrate with C-compatible components is a crucial feature of the language. In fact, Python's role as an extension and interface language in larger systems is one of the reasons for its popularity and why it is often called a "scripting" language. Its design supports hybrid systems that mix components written in a variety of programming languages. Because different languages have different strengths, being able to pick and choose on a component-by-component basis is a powerful concept. You can add Python to the mix anywhere you need an easy-to-use and flexible language tool, without sacrificing raw speed where it matters.
For instance, compiled languages such as C and C++ are optimized for speed of execution, but are complex to programfor developers, and especially for end users. Because Python is optimized for speed of development, using Python scripts to control or customize software components written in C or C++ can yield more flexible systems and dramatically faster development modes. Moreover, systems designed to delegate customizations to Python scripts don't need to be shipped with full source code and don't require end users to learn complex or proprietary languages. Moving selected components of a pure Python program to C can also optimize program performance.