GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - fpoli/python-c-api: Python/C API quick example

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
Makefile
Makefile
 
 
Readme.md
Readme.md
 
 
equivalent_fib.py
equivalent_fib.py
 
 
equivalent_hello.py
equivalent_hello.py
 
 
fibmodule.c
fibmodule.c
 
 
hellomodule.c
hellomodule.c
 
 

Repository files navigation

Python/C API quick start

A quick example of Python 3.10 modules implemented in C using the Python/C API.

make all
python -c "import hello; hello.greet('World')"
python -c "import fib; print(fib.fib(5))"
make clean

Note that the best way to distribute a Python module is to use a setup.py file. The Makefile is here only to debunk Python's magic.

Steps

  1. Write a foobarmodule.c C file. Note the #include <Python.h> at the beginning of example files.
  2. Compile foobarmodule.c and produce a foobar.so file. See the Makefile for details.
  3. Put foobar.so in a folder listed in the Python path.
  4. Load the module from Python with import foobar.

About

Python/C API quick example

Resources

Readme
Activity

Stars

21 stars

Watchers

1 watching

Forks

12 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.