Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 858 Bytes

File metadata and controls

30 lines (20 loc) · 858 Bytes

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