{"id":19519867,"url":"https://github.com/dahlitzflorian/extending-python-with-c","last_synced_at":"2026-04-30T12:32:10.599Z","repository":{"id":102340548,"uuid":"181149147","full_name":"DahlitzFlorian/extending-python-with-c","owner":"DahlitzFlorian","description":"Extending Python with C","archived":false,"fork":false,"pushed_at":"2019-04-14T19:53:14.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T00:24:33.693Z","etag":null,"topics":["c","educational","python","python-3","python-c-api","python3"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DahlitzFlorian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-13T09:31:12.000Z","updated_at":"2019-04-14T19:53:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"1031de53-3b2c-466a-a6de-0fae896dbf5c","html_url":"https://github.com/DahlitzFlorian/extending-python-with-c","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DahlitzFlorian/extending-python-with-c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DahlitzFlorian%2Fextending-python-with-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DahlitzFlorian%2Fextending-python-with-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DahlitzFlorian%2Fextending-python-with-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DahlitzFlorian%2Fextending-python-with-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DahlitzFlorian","download_url":"https://codeload.github.com/DahlitzFlorian/extending-python-with-c/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DahlitzFlorian%2Fextending-python-with-c/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32465009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","educational","python","python-3","python-c-api","python3"],"created_at":"2024-11-11T00:22:19.249Z","updated_at":"2026-04-30T12:32:10.572Z","avatar_url":"https://github.com/DahlitzFlorian.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Extending Python with C\n\n![black](https://img.shields.io/badge/code%20style-black-000000.svg)\n\n\n## Description\n\nThis repository contains a examples revealing how to extend Python with C code.\nIt's inspired by a [Medium article][mediumarticle] from [Matthias Bitzer][authorcredit] and the [Python Documentation][pythondocs].\n\n\n## Usage\n\nIf you want to run the modules in Python, you can install them using the provided `setup.py`.\nI recommend creating a virtual environment before installing them.\n\n\n### Unix\n\n```shell\n$ python -m venv venv\n$ source venv/bin/activate\n```\n\n\n### Windows\n\n```shell\n$ python -m venv venv\n$ venv\\bin\\activate\n```\n\n\n### Installation\n\nThe following command will install the modules in the `site-packages` directory of your current environment.\n\n```shell\n$ python setup.py install\n```\n\nYou can also *only* build the modules using:\n\n```shell\n$ python setup.py build\n```\n\nThis creates a new directory called `build`.\nChange your working directory to the one containing the `.so` libraries (`.dll` under Windows).\nCreating a Python session in this directory gives you access to the modules even though they are not installed.\n\n\n### Docker\n\nIf you want to test the modules in a Docker container to not mess up your own environment, you can run the following commands:\n\n```shell\n$ docker image build -t cmodules .\n$ docker container run --rm --name cmodules -it cmodules\n```\n\nAfter running the container a Python REPL is started were you can import the necessary modules.\nAn example is given below.\n\n```shell\nPython 3.7.3 (default, Mar 27 2019, 23:40:30) \n[GCC 6.3.0 20170516] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e from ccodemath import factorial\n\u003e\u003e\u003e factorial(6)\n720\n\u003e\u003e\u003e factorial(\"6\")\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nTypeError: an integer is required (got type str)\n\u003e\u003e\u003e quit()\n```\n\n\n## Available Modules\n\n| Module Name | Description |\n|-------------|-------------|\n| ccodemath | A collection of mathematical functions |\n\n\n[authorcredit]: https://medium.com/@matthiasbitzer94\n[mediumarticle]: https://medium.com/@matthiasbitzer94/how-to-extend-python-with-c-c-code-aa205417b2aa\n[pythondocs]: https://docs.python.org/3/extending/extending.html#a-simple-example\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahlitzflorian%2Fextending-python-with-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdahlitzflorian%2Fextending-python-with-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdahlitzflorian%2Fextending-python-with-c/lists"}