Abstract
In many modern software systems, programs are written in multiple languages to balance performance and productivity. For the CPython runtime, modules are frequently implemented in C to enhance execution speed or interface with existing libraries. To ensure the correctness of such modules, developers must not only implement the intended functionality and maintain memory safety but also adhere to API rules and preserve runtime invariants. In this paper, we present the first cross-language deductive verification technique for Python modules written in C. We define high-level semantic specification constructs and use them to bridge the abstraction gap between the two languages, translating Python contracts for the Nagini verifier into corresponding C contracts for VeriFast. We further provide a formal specification of a subset of the Python C API to ensure safety and the preservation of critical invariants, such as correct reference counting. We evaluate our implementation through a case study, demonstrating that our approach can successfully verify realistic “glue code” used in multi-language applications.