Skip to content

keikoro/extending_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extending Python (with C) – example project

C extension for a module with a method to look up Pokémon by their index number.

Project based on information found in a blog post on writing extensions by Adam Lamers, the official Python documentation on building C and C++ extension and various other bits and pieces on the topic found online.

Installation

Make sure to work in a virtual environment if you want to install the extension with pip.

In your venv, run:

$ pip install .

to have pip install the extension using setup.py.

Alternatively, you can run setup.py manually with:

$ python3 setup.py build_ext --inplace

to have the C code compiled into a shared object file (.so) in your venv.

Usage

To start the Python script with which you can test the module, use:

$ python3 test_extension.py

Resources

The Pokédex (index or "catalogue" of all Pokémon) used in this example project is based on the list of Pokémon found on The Pokémon Wiki.

About

Small example project to demonstrate how to extend Python with C code 🐍🆕

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published