Outline updated November 2026
C Programming for Python Programmers
Class Duration
21 hours of live training delivered over 3 days.
Student Prerequisites
- Prior programming experience in some language (Python knowledge is helpful but optional)
- Comfortable writing simple scripts using basic data types and program structures
- Comfortable working in your operating system and a terminal
Target Audience
- Python developers who need to read, write, debug, or wrap C code, such as C libraries, extension modules, and performance-critical routines
- Data, scientific, and machine learning engineers whose Python stack depends on compiled C libraries
- Developers from other high-level languages who want a practical, safety-conscious grounding in modern C
- Ready for more? Continue to High-Performance Python with C, C++, and Cython
Description
This course teaches modern C to Python developers and others who want to write C libraries and call them from Python. It uses the current C standard, with features such as nullptr, constexpr objects, typeof, and checked integer arithmetic. Memory safety runs through every module, with compiler warnings, sanitizers, static analysis, and safe coding practices. The final part connects C to Python with ctypes, NumPy arrays, and simple C extensions.
Learning Outcomes
- Set up a C development environment with a compiler, build tools, and a debugger.
- Write, compile, and run C programs and shared libraries.
- Organize code through functions, header files, and include files.
- Apply static typing, pointers, and dynamic memory allocation correctly.
- Use modern C language features to write clearer and safer C.
- Find memory and undefined-behavior bugs with sanitizers, compiler warnings, and static analysis.
- Apply memory-safety practices for buffers, strings, ownership, and integer arithmetic.
- Call C code from Python with ctypes and simple C extensions.
Training Materials
All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples. Students practice the topics covered through challenging hands-on lab exercises.
Software Requirements
Students will need a free, personal GitHub account to access the courseware. Students will need permission to install Python, a C compiler with C23 support (GCC or Clang), and Visual Studio Code on their computers. Also, students will need permission to install Python Packages and Visual Studio Code extensions. If students are unable to configure a local environment, a cloud-based environment can be provided.
Training Topics
Development Environment
- Installing GCC and Clang
- Visual Studio Code extensions for C
- Debugging C with VS Code and GDB or LLDB
C Programming Language
- Development tools
- Make
- CMake
- Cppcheck and clang-tidy
- Program structure
- The
mainfunction - Include files
- Header files
- Compiling to an executable
- Compiling to a shared library
- Using libraries
- Common compile options
- Selecting the C standard
- The
- Data types
- Numbers and fixed-width integer types
- Strings as character arrays
- Arrays
- Structs and unions
- Enums
- Typedefs
- Type casting
- Static vs. dynamic typing
- Loose vs. strong typing
- Static types
Modern C Essentials
- What changed in modern C
nullptrandnullptr_tbool,true, andfalseas keywordsconstexprobjects andstatic_asserttypeofandautotype inference- Standard attributes such as
[[nodiscard]] - Binary literals and digit separators
- Empty initializers with
{} - Checked integer arithmetic with
<stdckdint.h> - Embedding binary data with
#embed
Control Flow
- If
- Switch
- While
- Do-while
- For
- Goto and cleanup labels
Functions
- Defining a function
- Calling a function
- Passing arguments
- Return values
- Function pointers
Pointers
- Pass by value vs. pass by reference
- Allocating memory on the heap
- Dynamic memory allocation practices
- Linked lists
- Untyped pointers
Finding Bugs: Sanitizers and Analysis
- Compiler warnings as a first defense
- AddressSanitizer
- Buffer overflows, use-after-free, and double free
- UndefinedBehaviorSanitizer
- Signed overflow and invalid shifts
- LeakSanitizer and Valgrind for memory leaks
- Static analysis with Cppcheck, clang-tidy, and GCC's analyzer
- Fuzzing with libFuzzer
Memory-Safety Practices
- Understanding undefined behavior
- Bounds-checked buffer and string handling
- Avoiding
gets,strcpy, andsprintf - Ownership conventions for allocated memory
- Initializing variables and clearing freed pointers
- Preventing integer overflow in size calculations
_FORTIFY_SOURCEand stack protection- Where memory-safe languages fit alongside C
Python and C Integration
- NumPy arrays and C memory layout
- The ctypes FFI
- Python
structmodule and ctypesStructure - Creating a simple C extension
- Debugging a C extension
- Reviewing C code generated by Cython
- Basic profiling of C functions