{"id":16276554,"url":"https://github.com/virgesmith/pybind11-examples","last_synced_at":"2025-08-29T17:27:34.859Z","repository":{"id":225663819,"uuid":"766137804","full_name":"virgesmith/pybind11-examples","owner":"virgesmith","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-19T08:45:01.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T02:47:06.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/virgesmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-02T12:51:04.000Z","updated_at":"2024-11-19T08:45:06.000Z","dependencies_parsed_at":"2024-03-16T15:06:10.926Z","dependency_job_id":"32514bc2-f648-4e13-b634-80e6da319363","html_url":"https://github.com/virgesmith/pybind11-examples","commit_stats":null,"previous_names":["virgesmith/pybind11-examples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/virgesmith/pybind11-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgesmith%2Fpybind11-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgesmith%2Fpybind11-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgesmith%2Fpybind11-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgesmith%2Fpybind11-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virgesmith","download_url":"https://codeload.github.com/virgesmith/pybind11-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgesmith%2Fpybind11-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272732746,"owners_count":24984225,"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-08-29T02:00:10.610Z","response_time":87,"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":[],"created_at":"2024-10-10T18:48:53.527Z","updated_at":"2025-08-29T17:27:34.815Z","avatar_url":"https://github.com/virgesmith.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pybind11-examples\n\nA python extension module written in C++ with pybind11 bindings, containing implementations of various constructs, including:\n\n- [X] generators, including `send`, `close`, and `throw` methods\n- [X] `__init_subclass__` - using it to register subclasses\n- [X] decorators, simple and parameterised\n- [X] a context manager\n- [X] some prime number stuff, for performance comparison aginst equivalent python and rust implementations.\n- [X] polymorphism across C++ and python (subclassing C++ classes in python, calling python overrides through a C++ interface)\n- [X] ~~dynamic immutable values wrapped in a `Constants` singleton that can be trivially reassigned, so it's pointless.~~\n- [X] C and C++ enumerations\n- [X] vectorised functions with a performance comparison against python and vectorised numpy\n- [X] type annotations for C++ implementations\n\nMost of the code originated in [this](http://github.com/virgesmith/poetry-pybind11-integration) project which was originally intended to demonstate how to make pybind11 work with poetry. The project evolved and became more about:\n- how to implement certain python constructs in C++\n- performance comparison between python modules implemented in python, [rust](https://github.com/virgesmith/poetry-rust-integration/) and C++\n\n# usage\n\nBuild and install the package:\n\n```sh\npip install -e .[dev]\n```\n\nTest:\n\n```sh\npytest\n```\n\nPerformance (vectorisation comparison):\n\n```sh\npython test/test_vectorised.py\n```\n\nUse, e.g.:\n\n```py\nfrom pybind11_examples import FibGenerator, Collatz\n\nfg = FibGenerator()\nprint([next(fg) for _ in range(10)])\n\nprint(list(Collatz(19)))\n```\n\n## Type annotations\n\nType stubs are generated based on the signatures and docstrings in [module.cpp](src/module.cpp), using the `pybind11-stubgen` package directly on the C++ shared object, like so:\n\n```\npybind11-stubgen _pybind11_examples\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgesmith%2Fpybind11-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirgesmith%2Fpybind11-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgesmith%2Fpybind11-examples/lists"}