Category: Python
Having to write your own Python extensions in C can be caused by different circumstances. You might need to use a library, which is available only from the C level, for example OpenSSL bignum. Sometimes, performance requirements for a certain fragment of the codebase make an implementation in C the only possible solution. Other times you need to use a system call which is unavailable from Python and writing C code is the only way to get to it.
In this training we will show you how to write Python extensions, how to easily call functions from libraries without Python interfaces and how to connect code written in high level languages (like Python) with bits of low level code in C. We will take a closer look at Python’s garbage collection system and the ways in which our code can cooperate with it. We will describe the most common problems and how to solve them.
Our trainers are seasoned Python developers, with many years of experience in creating applications in Python, including writing custom C extensions.
Duration
1 day
Agenda
- Python interfaces for C
- Defining functions
- Fetching and returning data
- Cooperation with the garbage collector
- Defining classes and exceptions
- Working with the GIL
- Compilation
- the _setup.py_file, defining extensions
- Linking dynamic libraries
- Writing portable code
- Other methods of mixing Python and C
- the ctypes library
- Loading shared libraries
- Calling functions, passing arguments
- Writing programs in Pyrex
- Embedding the Python interpreter in C programs
During our courses we use the latest Python version (branch 2). In case of on-demand courses, it’s possible to use any version required by the Client, according to his needs.
- the ctypes library
Audience and prerequisites
Good knowledge of Python, solid knowledge of C, experience in compiling software on Linux.
Certificates
Course participants receive completion certificates signed by ALX.