Chapter 16. Extending IronPython Using C#

WHAT'S IN THIS CHAPTER?

  • Defining the requirements for an extension

  • Understanding how static language differences affect extensions

  • Developing a simple C# extension

  • Providing user interface support through a C# extension

  • Providing Win32 API support through a C# extension

Many developers view C# as the new C. It's true that C# does provide many of the low-level characteristics of C, but it's not really a replacement. Even so, C# is a good language choice for many tasks, especially when it comes to working through difficulties with Win32 API (the programming interface that native code executables use). Because IronPython lacks support for certain low-level operations, you'll find many ways to use C# to extend IronPython to perform amazing new tasks.

Of course, it's important to know precisely what an extension is, so this chapter spends some time exploring the issue. As with many software constructs, extensions aren't a complete fix for every problem — they have both advantages and disadvantages that you need to consider during the design process. Extensions are an important tool in your IronPython toolkit and act as a replacement for the lack of CPython support in many cases.

This chapter provides a simple extension. You can use this simple example as a starting point for other extensions you might want to create. Of course, even a simple example can take you a long way in understanding extension techniques.

After you complete the simple extension, ...

Get Professional IronPython™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.