[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

Reusability
Because Python is a high-level, object-oriented language, it encourages writing re-
usable software and well-designed systems.


Deliverability
Because Python is designed for use in mixed-language systems, we don’t have to
move to more efficient languages all at once.


In many scenarios, a system’s frontend and infrastructure may be written in Python for
ease of development and modification, but the kernel is still written in C or C++ for
efficiency. Python has been called the tip of the iceberg in such systems—the part visible
to end users of a package, as captured in Figure 21-6.


Figure 21-6. “Sinking the Titanic” with mixed-language systems


Such an architecture uses the best of both worlds: it can be extended by adding more
Python code or by writing C extension modules, depending on performance require-
ments. But this is just one of many mixed-language development scenarios:


System interfaces
Packaging libraries as Python extension modules makes them more accessible.


End-user customization
Delegating logic to embedded Python code provides for onsite changes.


Pure prototyping
Python prototypes can be moved to C all at once or piecemeal.


Legacy code migration
Moving existing code from C to Python makes it simpler and more flexible.


Standalone use
Of course, using Python all by itself leverages its existing library of tools.


Python’s design lets us apply it in whatever way makes sense for each project.


1554 | Chapter 21: Conclusion: Python and the Development Cycle

Free download pdf