ADBRITE ads links
You are here: CodeIdol.com > Python > Programming Python, 3rd Edition > Extending Python
Programming Python, 3rd Edition
| 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...
|
|
| 22.2. Integration Modes
The last two technical chapters of this book introduce Python's tools for interfacing to the outside world and discuss both its ability to be used as an embedded language tool in other systems and its interfaces for...
|
|
| 22.3. C Extensions Overview
Because Python itself is coded in C today, compiled Python extensions can be coded in any language that is C compatible in terms of call stacks and linking. That includes C, but also C++ with appropriate "extern C"...
|
|
| 22.4. A Simple C Extension Module
At least that's the short story; we need to turn to some code to make this more concrete. C types generally export a C module with a constructor function. Because of that, and because they are simple...
|
|
| 22.5. Extension Module Details
Now that I've shown you the somewhat longer story, let's fill in the rest. The next few sections go into more detail on compilation and linking, code structure, data conversions, error handling, and refere...
|
|
| 22.6. The SWIG Integration Code Generator
But don't do that. As you can probably tell, manual coding of C extensions can become fairly involved (this is almost inevitable in C language work). I've introduced the basics in this chapter thus far so ...
|
|
| 22.7. Wrapping C Environment Calls
Let's move on to a more useful application of C extension modules. The handcoded C file in Example 22-9 integrates the standard C library's getenv and putenv shell environment variable calls for use in Py...
|
|
| 22.8. A C Extension Module String Stack
Let's kick it up another notchthe following C extension module implements a stack of strings for use in Python scripts. Example 22-15 demonstrates additional API calls, but it also serves as a basis of ...
|
|
| 22.9. A C Extension Type String Stack
So far in this chapter, we've been dealing with C extension modulesflat function libraries. To implement multiple-instance objects in C, you need to code a C extension type, not a module. Like Python classes, ...
|
|
| 22.10. Wrapping C++ Classes with SWIG
One of the more clever tricks SWIG can perform is class wrapper generation. Given a C++ class declaration and special command-line settings, SWIG generates the following:
A C++-coded Python extension module w...
|
|
| 22.11. Other Extending Tools
In closing the extending topic, I should mention that there are alternatives to SWIG, some of which have a loyal user base of their own. This section briefly introduces some of the more popular tools in this domai...
|
|
You are here: CodeIdol.com > Python > Programming Python, 3rd Edition > Extending Python
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|