{"id":19353404,"url":"https://github.com/brandtbucher/pycapi","last_synced_at":"2025-10-10T05:33:07.801Z","repository":{"id":62579162,"uuid":"178346539","full_name":"brandtbucher/pycapi","owner":"brandtbucher","description":"Over 600 fast Python bindings to the CPython C API. 🤯","archived":false,"fork":false,"pushed_at":"2024-09-03T21:35:13.000Z","size":365,"stargazers_count":61,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-15T13:54:07.253Z","etag":null,"topics":["api","c","cpython","python"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brandtbucher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-03-29T06:33:02.000Z","updated_at":"2025-07-02T14:41:16.000Z","dependencies_parsed_at":"2024-11-10T04:43:02.944Z","dependency_job_id":"2ba816e6-4cf6-4af3-b80b-57b8f9d8eb3e","html_url":"https://github.com/brandtbucher/pycapi","commit_stats":{"total_commits":324,"total_committers":4,"mean_commits":81.0,"dds":0.01851851851851849,"last_synced_commit":"38d4e690897f9756b9fb492ecea1f6834b143686"},"previous_names":[],"tags_count":87,"template":false,"template_full_name":null,"purl":"pkg:github/brandtbucher/pycapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandtbucher%2Fpycapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandtbucher%2Fpycapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandtbucher%2Fpycapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandtbucher%2Fpycapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brandtbucher","download_url":"https://codeload.github.com/brandtbucher/pycapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandtbucher%2Fpycapi/sbom","scorecard":{"id":251369,"data":{"date":"2025-08-11","repo":{"name":"github.com/brandtbucher/pycapi","commit":"38d4e690897f9756b9fb492ecea1f6834b143686"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/brandtbucher/pycapi/ci.yml/master?enable=pin","Info:   0 out of   7 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: PYSEC-2013-22 / GHSA-27x4-j476-jp5f","Warn: Project is vulnerable to: PYSEC-2025-49 / GHSA-5rjg-fvgr-3xxf","Warn: Project is vulnerable to: GHSA-cx63-2mw6-8hw5","Warn: Project is vulnerable to: PYSEC-2022-43012 / GHSA-r9hx-vwmv-q579","Warn: Project is vulnerable to: PYSEC-2022-43017 / GHSA-qwmp-2cf2-g9g6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T08:32:20.698Z","repository_id":62579162,"created_at":"2025-08-17T08:32:20.698Z","updated_at":"2025-08-17T08:32:20.698Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002867,"owners_count":26083468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"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":["api","c","cpython","python"],"created_at":"2024-11-10T04:42:50.107Z","updated_at":"2025-10-10T05:33:07.784Z","avatar_url":"https://github.com/brandtbucher.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=justify\u003e\n\n\u003cdiv align=center\u003e\n\nPyCAPI\n======\n\n[![latest version](https://img.shields.io/github/release-pre/brandtbucher/pycapi.svg?style=for-the-badge\u0026label=latest)![latest release date](https://img.shields.io/github/release-date-pre/brandtbucher/pycapi.svg?style=for-the-badge\u0026label=released)](https://github.com/brandtbucher/pycapi/releases)[![build status](https://img.shields.io/github/actions/workflow/status/brandtbucher/pycapi/ci.yml.svg?style=for-the-badge\u0026branch=master)](https://github.com/brandtbucher/pycapi/actions)[![issues](https://img.shields.io/github/issues-raw/brandtbucher/pycapi.svg?label=issues\u0026style=for-the-badge)](https://github.com/brandtbucher/pycapi/issues)\n\n\u003cbr\u003e\n\n\u003c/div\u003e\n\nPyCAPI is a Python package containing over 600 fast bindings to the CPython C API. Its goal is to support as many of the Python 3.7 - 3.11 stable public APIs as possible.\n\nTo install, just run:\n```sh\n$ pip install pycapi\n```\n\nWhere is the documentation?\n---------------------------\n\nDocumentation of the full CPython C API can be found [here](https://docs.python.org/3/c-api/index.html). It's not a goal of this project to maintain a separate API reference.\n\nAny type conversions (such as Python `int` with C `long`, or Python `bytes` with C `char*`) should be obvious, and all other semantics (such as refcounts, etc.) are identical to the documented API behavior. For simplicity, PyCAPI doesn't provide any additional functionality or utilities beyond CPython's documented stable public API.\n\nHow is PyCAPI better than `ctypes.pythonapi`?\n---------------------------------------------\n\n### It's easier to use.\n\n`pycapi` works as expected, right out of the box:\n\n```py\n\u003e\u003e\u003e import pycapi\n\u003e\u003e\u003e pycapi.PyNumber_Add(1, 2)\n3\n```\n\n`ctypes.pythonapi` implicity requires users to specify the argument and return types as `ctypes` types:\n\n```py\n\u003e\u003e\u003e import ctypes\n\u003e\u003e\u003e ctypes.pythonapi.PyNumber_Add(1, 2)\nSegmentation fault: 11\n```\n\n```py\n\u003e\u003e\u003e import ctypes\n\u003e\u003e\u003e ctypes.pythonapi.PyNumber_Add.argtypes = (ctypes.py_object, ctypes.py_object)\n\u003e\u003e\u003e ctypes.pythonapi.PyNumber_Add.restype = ctypes.py_object\n\u003e\u003e\u003e ctypes.pythonapi.PyNumber_Add(1, 2)\n3\n```\n\n### It's more complete.\n\n`pycapi` is designed to provide properly typed bindings for *any* part of the C API that's reasonable to call from the Python layer:\n\n```py\n\u003e\u003e\u003e import pycapi\n\u003e\u003e\u003e pycapi.PyDict_Check({})\n1\n```\n\nIn comparison, `ctypes.pythonapi` is loaded directly from the `Python.h` DLL. As a consequence, it isn't able to offer any APIs that happen to be implemented as macros:\n\n```py\n\u003e\u003e\u003e import ctypes\n\u003e\u003e\u003e ctypes.pythonapi.PyDict_Check(ctypes.py_object({}))\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n  File \"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py\", line 369, in __getattr__\n    func = self.__getitem__(name)\n  File \"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py\", line 374, in __getitem__\n    func = self._FuncPtr((name_or_ordinal, self))\nAttributeError: dlsym(RTLD_DEFAULT, PyDict_Check): symbol not found\n```\n\n`pycapi` is also fully loaded on import, so you can use tab-completion and other introspection techniques to discover APIs (it's also fully typed, so linters and other static editing tools \"just work\"). `ctypes.pythonapi` requires you to access the attribute *before* it is loaded, and there is no way to get a complete listing of what it supports.\n\n### It's faster.\n\nIn many cases, it can be even *faster than the built-in equivalent* in the Python layer. The numbers speak for themselves:\n\n```py\nIn [1]: from pycapi import PyDict_New, PyDict_Clear, PyDict_Copy\n\nIn [2]: %timeit PyDict_New()\n44.7 ns ± 1.38 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [3]: %timeit PyDict_Clear({})\n54 ns ± 0.448 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [4]: %timeit PyDict_Copy({})\n68.9 ns ± 0.362 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n```\n\n```py\nIn [1]: PyDict_New = dict\n   ...: PyDict_Clear = dict.clear\n   ...: PyDict_Copy = dict.copy\n\nIn [2]: %timeit PyDict_New()\n71.7 ns ± 0.569 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [3]: %timeit PyDict_Clear({})\n55.8 ns ± 0.506 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [4]: %timeit PyDict_Copy({})\n73.1 ns ± 1.06 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n```\n\n```py\nIn [1]: import ctypes\n   ...:\n   ...: PyDict_New = ctypes.pythonapi.PyDict_New\n   ...: PyDict_New.argtypes = ()\n   ...: PyDict_New.restype = ctypes.py_object\n   ...:\n   ...: PyDict_Clear = ctypes.pythonapi.PyDict_Clear\n   ...: PyDict_Clear.argtypes = (ctypes.py_object,)\n   ...: PyDict_Clear.restype = None\n   ...:\n   ...: PyDict_Copy = ctypes.pythonapi.PyDict_Copy\n   ...: PyDict_Copy.argtypes = (ctypes.py_object,)\n   ...: PyDict_Copy.restype = None\n\nIn [2]: %timeit PyDict_New()\n113 ns ± 0.424 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [3]: %timeit PyDict_Clear({})\n273 ns ± 3.34 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)\n\nIn [4]: %timeit PyDict_Copy({})\n378 ns ± 9.77 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)\n```\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandtbucher%2Fpycapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandtbucher%2Fpycapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandtbucher%2Fpycapi/lists"}