Course Data

Course name: Python Extensions with Other Languages
Course length: 1 day
Remote: Yes
Open course: No
In-house: Yes
Course ID: EXE
German course here

Course Finder

Find the right course for your needs..

Combining Topics

Company courses allow to assemble trainings combining topics from different courses.

Course Topics Overview as PDF

You can download our flyer. It has an overview of all our course topics.

Python-Extensions with Other Languages

Motivation

Python can be readily connected with other languages. This way, existing libraries in other languages can be used.

Programming in Python is rather comfortable and efficient. The speed of Python programs for some tasks is considerably slower than for programs in other languages such as C/C++, C#, Java, or FORTRAN. As a solution slow program parts can be reimplemented in other languages and seamlessly incorporated in Python.

Furthermore, Python is often termed “glue languages” because of its ability to connected very different systems. The connection of libraries and programs that are implemented in other languages plays a important role for this ability.

Course Content

Introduction to Example

We use a computationally intensive example throughout the course. This allows for comparison of the different extension methods.

Use of Python’s C-API

Standard Python is implemented in C and offers a comprehensive API for writing extensions. The basics of this API are taught. A working extension will be developed by hand that can be used by a Python program.

Python Extensions with Pyrex/Cython

Pyrex is a special language for writing Python extensions. It has mainly Python syntax with some limitations and some additions that allow for automatic translation into C code suitable to be compiled in an Python extension. Examples are used to show how Pyrex works. The possibilities of incorporating existing C programs are also explained.

Use of DLLs with ctypes

The package ctypes allows to access DLLs or shared libraries from Python. It works on the operating systems Windows, Windows CE, Mac OS X, Linux, Solaris, FreeBSD, and OpenBSD. The language in which the DLL is implemented doesn’t matter. The usage of ctypes is introduced with examples. Under Windows Microsoft’s .NET compiler und the mingw (gcc) compiler are used to compile the DLL. The shared library under Linux Linux is compiled with the gcc. One focus is type conversion between Python and the DLL.

Automatic generation of Extensions with SWIG

The “Simplified Wrapper and Interface Generator” (SWIG) allows to make C/C++ libraries accessible from 13 different languages. One of them is Python. The way SWIG works is covered using examples in C as well as in C++.

Jython

Jython is an implementation of Python in Java. It allows to access Java classes directly. The course covers the basics of Jython programs. Examples for use of existing Java classes as well as self written classes are used.

IronPython

IronPython is a implementation of Python in .NET. It allows Access to all .NET features and makes it a first class .NET language right next to C# and Visual Basic. The course introduces IronPython, demonstrates how to use .NET assemblies, and how access self written C# classes.

Use of FORTRAN Subroutines from Python

FORTRAN is one of the oldest programming languages but it is still in heavy use for scientific applications due to its high performance. There are many old but well proven numerical libraries that can be used from Python.

The usage of F2PY to connect FORTRAN77 as well as FORTRAN90/95 programs with Python is demonstrated. One focus are object-oriented interfaces to those libraries.

Exercises

The participants can follow all steps directly on their computers. There are exercises at the end of each unit providing ample opportunity to apply the freshly learned knowledge.

Course Material

Every participant receives comprehensive materials in PDF format that cover the whole course content as well as all source code.

How to contact us:
Python Academy GmbH & Co. KG
Zur Schule 20
04158 Leipzig / Germany
Tel:+49 341 260 3370
Fax:+49 341 520 4495
mail:info@python-academy.de
How to contact us:
Python Academy GmbH & Co. KG
Zur Schule 20
04158 Leipzig / Germany
Tel:+49 341 260 3370
Fax:+49 341 520 4495
mail:info@python-academy.de