{"id":16927204,"url":"https://github.com/dubzzz/py2cpp","last_synced_at":"2025-09-11T22:40:00.991Z","repository":{"id":66112782,"uuid":"38131889","full_name":"dubzzz/Py2Cpp","owner":"dubzzz","description":"Convert PyObject* to C++ datatypes and vice versa","archived":false,"fork":false,"pushed_at":"2016-11-20T12:03:10.000Z","size":91,"stargazers_count":29,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T17:50:50.354Z","etag":null,"topics":["conversion","cpp","python"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/dubzzz.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}},"created_at":"2015-06-26T20:22:46.000Z","updated_at":"2024-08-12T19:08:14.000Z","dependencies_parsed_at":"2023-03-10T23:37:16.792Z","dependency_job_id":null,"html_url":"https://github.com/dubzzz/Py2Cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dubzzz/Py2Cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubzzz%2FPy2Cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubzzz%2FPy2Cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubzzz%2FPy2Cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubzzz%2FPy2Cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dubzzz","download_url":"https://codeload.github.com/dubzzz/Py2Cpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubzzz%2FPy2Cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274719238,"owners_count":25337237,"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-09-11T02:00:13.660Z","response_time":74,"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":["conversion","cpp","python"],"created_at":"2024-10-13T20:33:19.236Z","updated_at":"2025-09-11T22:40:00.961Z","avatar_url":"https://github.com/dubzzz.png","language":"C++","readme":"# Py2Cpp [![Build Status](https://travis-ci.org/dubzzz/Py2Cpp.svg?branch=master)](https://travis-ci.org/dubzzz/Py2Cpp)[![Coverage Status](https://coveralls.io/repos/dubzzz/Py2Cpp/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/dubzzz/Py2Cpp?branch=master)\n\n## Metaprogramming serving Py-\u003eC++ and C++-\u003ePy\n\nThis library makes it easy to convert Python objects (Python C API) to standard C++ datatypes. It is based on a single header file that uses templates and variadic templates in order to perform the conversions. It requires C++11 or superior.\n\n## How to use it?\n\n### Python objects towards C++ instances\n\n#### Basic usages: std datatypes\n\nThe file ```src/py2cpp.hpp``` defines the functor ```CppBuilder\u003cT\u003e```, which is responsible to build the corresponding C++ element of a given PyObject instance automatically. A same functor can be use for several PyObject.\n\nFor the moment, the conversion from Python to C++ can generate combinations of the following datatypes:\n- ```PyObject*```\n- ```bool```\n- ```int``` and ```unsigned int```\n- ```long``` and ```unsigned long```\n- ```long long``` and ```unsigned long long```\n- ```double```\n- ```std::string``` and ```std::wstring```\n- ```std::map``` -- from ```dict```\n- ```std::set``` -- from ```set```\n- ```std::tuple``` -- from ```tuple```\n- ```std::vector``` -- from ```list```\n\nConverting a PyObject* to a C++ element is as simple as: ```T my_cpp_elt { CppBuilder\u003cT\u003e()(py_object) };``` where ```T``` should be replace by the conjonction of datatypes you want.\n\nFor instance, if a PyObject* contains a ```dict(tuple(int,int,double),list(int))```, you can easily convert it into C++ datatypes by using:\n\n```\nauto out { CppBuilder\u003cstd::map\u003cstd::tuple\u003cint,int,double\u003e,std::vector\u003cint\u003e\u003e\u003e()(py_object) };\n```\n\n#### More advance usages: fill your own struct/class\n\nTo describe...\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubzzz%2Fpy2cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdubzzz%2Fpy2cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubzzz%2Fpy2cpp/lists"}