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.
- uv
- A C compiler (gcc, clang, or MSVC)
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'))"uv add --dev pytest
uv run pytest test_string_utils.py -vMIT