Back to search

Kent State University

Assessing Python Bindings of C Libraries with Respect to Python Idiomatic Conformance

Abstract

dc:description

In the development of Python bindings of C libraries, developers often mirror thestyling and practices of C code onto the Python module. These modules do not integratewell within standard Python code, causing a clash of coding idioms and introducing thecomplexities of low-level C features not present in Python. Such complexities includemanual memory management, procedural code in an object-oriented paradigm, and lack ofintegration into standard Python features.The thesis proposes a set of Python binding idioms to serve as guidelines whiledeveloping a binding for a C library. These idioms are based on related literature thatdefines 21 Pythonic idioms for use in general coding to improve a program’s readabilityand performance. The 11 idioms defined here include: Iteration, Context Managing,Casting, Printability, Mapping Structures to Classes, Maintaining Free Functions,Destructors, Rasing Errors, Docstrings, Annotations, and Selective Importing. Alongsidethese, four standard rules for method, class, and variable naming are also defined. Theseidioms and naming standards are designed to help a Python programmer understand anduse a binding module by improving how Python interacts with the C library.A number of these idioms are identifiable in a Python binding via built-in Pythontools such as dir. To measure how well current Python bindings use these idioms, a set of7 Python bindings are analyzed to detect if these idioms are present in a given binding. Forthe idioms that cannot be completely verified through the Python library alone, the Clibrary that the binding uses is also analyzed, and then compared to the Python binding forverification. The Python bindings that are chosen are all official bindings developed by orpromoted by the original authors of the C libraries. Additionally, two commonly acceptedPythonic modules are also analyzed for comparison.As a case study these idioms are applied to the development of the pylibsrcmlmodule. pylibsrcml is a Python binding of the opensource libsrcml C library. pylibsrcmlhas gone through many development iterations throughout its lifecycle. The most recentversion of pylibsrcml, which makes use of all the defined idioms, is described andcontrasted against the previous versions to show that it is more Pythonic.

Degree

thesis:*
Name thesis:degree_name
MS
Level thesis:degree_level
masters
Discipline thesis:degree_discipline
College of Arts and Sciences / Department of Computer Science
Grantor dc:publisher
Kent State University
Year dc:date
2023

Author and committee

dc:creator, dc:contributor.*
Author dc:creator
  • Behler, Joshua Allan Charles
Advisor dc:contributor.advisor
  • Maletic, Jonathan

Subjects

dc:subject × 3

Rights

dc:rights
Statement dc:rights
  • unrestricted
  • This thesis or dissertation is protected by copyright: all rights reserved. It may not be copied or redistributed beyond the terms of applicable copyright laws.
Language dc:language
English

Identifiers

dc:identifier.*

Chain of custody

source
Harvested from
OhioLINK
Base URL
etd.ohiolink.edu/acprod/odb_etd/ws/oai/oai
Last updated
2026-11-27
Source record
OAI-PMH GetRecord
citation

Behler, Joshua Allan Charles. Assessing Python Bindings of C Libraries with Respect to Python Idiomatic Conformance. masters thesis, Kent State University, 2023. http://rave.ohiolink.edu/etdc/view?acc_num=kent1699882417467814