Skip to content

python-developer-tooling-handbook/python-c-extension-example

Repository files navigation

Python C Extension Example

A Python library with string utility functions implemented in C, using cffi.

This is the companion repository for the Build a Python library with a C extension tutorial on the Python Developer Tooling Handbook.

Prerequisites

  • uv
  • A C compiler (gcc, clang, or MSVC)

Getting Started

git clone https://github.com/python-developer-tooling-handbook/python-c-extension-example.git
cd python-c-extension-example
uv run python build_c.py
uv run python -c "from string_utils import word_count; print(word_count('hello world'))"

Running Tests

uv add --dev pytest
uv run pytest test_string_utils.py -v

License

MIT

About

Example Python library with a C extension using cffi and uv. Companion to pydevtools.com tutorial.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors