{"id":28714624,"url":"https://github.com/rsusik/pycerializer","last_synced_at":"2026-04-12T07:37:42.446Z","repository":{"id":57455758,"uuid":"390715688","full_name":"rsusik/pycerializer","owner":"rsusik","description":"PyCerializer is a lightweight serialization module for Python. This serializer allows easily deserialize the data in C/C++.","archived":false,"fork":false,"pushed_at":"2024-11-01T11:37:41.000Z","size":72,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-12T07:37:20.507Z","etag":null,"topics":["c","cpp","packing","python","serialization","serializer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsusik.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}},"created_at":"2021-07-29T12:24:34.000Z","updated_at":"2024-11-01T11:37:45.000Z","dependencies_parsed_at":"2022-09-05T18:12:27.071Z","dependency_job_id":null,"html_url":"https://github.com/rsusik/pycerializer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rsusik/pycerializer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpycerializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpycerializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpycerializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpycerializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsusik","download_url":"https://codeload.github.com/rsusik/pycerializer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsusik%2Fpycerializer/sbom","scorecard":{"id":787871,"data":{"date":"2025-08-11","repo":{"name":"github.com/rsusik/pycerializer","commit":"f3e83d746c54244e61ca631b1324201423a0c033"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: tests/__pycache__/tests.cpython-37.pyc:1"],"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"Code-Review","score":0,"reason":"Found 0/17 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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE:0"],"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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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"}}]},"last_synced_at":"2025-08-23T06:34:49.062Z","repository_id":57455758,"created_at":"2025-08-23T06:34:49.062Z","updated_at":"2025-08-23T06:34:49.062Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31707953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T06:22:27.080Z","status":"ssl_error","status_checked_at":"2026-04-12T06:21:52.710Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","cpp","packing","python","serialization","serializer"],"created_at":"2025-06-15T01:08:03.597Z","updated_at":"2026-04-12T07:37:42.438Z","avatar_url":"https://github.com/rsusik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/rsusik/pycerializer/raw/master/pycerializer.png\" alt=\"PyCerializer\" /\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cem\u003eLightweight serialization module for Python.\u003c/em\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://pypi.org/project/pycerializer\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/pycerializer?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/rsusik/pycerializer/blob/master/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/rsusik/pycerializer\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n\nPyCerializer is a lightweight serialization module for Python. \nThe aim of PyCerializer is to produce serialized data that \ncan be easily read in other programming languages such \nas C/C++ and others.\n\n## Requirements\nThere are no external dependencies.\nThe package is based on standard python module `struct`\nthat is available in all supported python versions, but\nthe PyCerializer use also `typing` module that was introduced \nin Python 3.5.\n\n## Supported types:\n\n- Numbers\n    - [u]int64_t\n    - [u]int32_t\n    - [u]int16_t\n    - [u]int8_t\n- Strings\n- Structures\n\n## Endianess:\n- little,\n- big.\n\n## Installation\n```\npip install pycerializer\n```\n\n## Examples\n\n### Serialize the Python list and save to file:\n```python\noriginal = (1, 123, 4321)\npacked = pack_list_num(original, 'int16_t', 'little')\nwith open('file.bin', 'wb') as f:\n    f.write(packed)\n```\n\n### Deserialize the list using Python:\n```python\nwith open('file.bin', 'rb') as f:\n    packed = f.read()\n    unpacked = unpack_list_num(*packed, 'int16_t', 'little')\n```\n\n### Deserialize the list using C/C++:\n```cpp\nFILE *f = fopen(\"file.bin\", \"rb\");\nconst int n = 3;\nint16_t buff[n];\nfread(buff, sizeof(int16_t), n, f);\nfor (int i = 0; i \u003c n; i++) printf(\"%d \", buff[i] );\n```\n\n### Serialize and deserialize the list of dictionaries:\n```python\n    # data\n    data = [{\n        'name': b'John',\n        'age': 34,\n        'height': 177,\n        'surname': b'Smith',\n        'weight': 86\n    }, \n    {\n        'name': b'Andrew',\n        'age': 43,\n        'height': 187,\n        'surname': b'Bluebaum',\n        'weight': 67\n    }, {\n        'name': b'Michael',\n        'age': 38,\n        'height': 189,\n        'surname': b'Brown',\n        'weight': 99\n    }]\n\n    # data field:type mapping\n    data_map = {\n        'name': 'string',\n        'age': 'int8_t',\n        'height': 'int32_t',\n        'surname': 'string',\n        'weight': 'int8_t'\n    }\n\n    # packing\n    data_bytes, data_elements, _, data_elements_size = pack_list_dict(data, data_map)\n\n    # unpacking\n    data_unpacked = unpack_list_dict(data_bytes, data_map, data_elements)\n\n    # metadata\n    meta = {\n        'number_of_elements': data_elements,\n    }\n\n    # metadata field:type mapping\n    meta_map = {\n        'number_of_elements': 'uint64_t'\n    }\n\n    meta_bytes, _ = pack_dict(meta, meta_map)\n    elements_size_bytes, _ = pack_list_num(data_elements_size, 'int64_t')\n\n    # write bytes to a file\n    with open('list_of_dicts.bin', 'wb') as f:\n        f.write(meta_bytes)\n        f.write(elements_size_bytes)\n        f.write(data_bytes)\n\n    # Get the C struct to use it later in C code\n    print(get_c_struct(meta_map, name='meta_t'))\n    print(get_c_struct(data_map, name='data_t'))\n```\n\n### Deserialize and print the data from file using C/C++:\n```cpp\n// Copied from Python output\ntypedef struct _meta_t {\n    uint64_t number_of_elements;\n} meta_t;\n\n\ntypedef struct _data_t {\n    char * name;\n    int8_t age;\n    int32_t height;\n    char * surname;\n    int8_t weight;\n} data_t;\n\n// Read the data from buffer\nsize_t data_t_read(data_t *obj, uint8_t *bytes) {\n    int64_t *name_size = (int64_t *)bytes;           bytes += sizeof(int64_t);\n    obj-\u003ename = (char*)calloc(*name_size + 1, sizeof(char));\n\n    memcpy(obj-\u003ename, bytes, *name_size);            bytes += *name_size;\n    memcpy(\u0026(obj-\u003eage), bytes, sizeof(uint8_t));     bytes += sizeof(uint8_t);\n    memcpy(\u0026(obj-\u003eheight), bytes, sizeof(uint32_t)); bytes += sizeof(uint32_t);\n\n    int64_t *surname_size = (int64_t *)bytes;        bytes += sizeof(int64_t);\n    obj-\u003esurname = calloc(*surname_size + 1, sizeof(char));\n\n    memcpy(obj-\u003esurname, bytes, *surname_size);      bytes += *surname_size;\n    memcpy(\u0026(obj-\u003eweight), bytes, sizeof(int8_t));   bytes += sizeof(int8_t);\n\n    return 0;\n}\n\n// Never forget to deallocate the memory\nvoid data_t_free(data_t obj) {\n    free(obj.name);\n    free(obj.surname);\n}\n\n\nint main() {\n    FILE *f = fopen(\"list_of_dicts.bin\", \"rb\");\n    meta_t meta;\n    fread(\u0026meta, sizeof(meta_t), 1, f);\n\n    data_t *data = (data_t*)malloc(sizeof(data_t) * meta.number_of_elements);\n    int64_t* sizes = (int64_t*)malloc(meta.number_of_elements * sizeof(int64_t*));\n    fread(sizes, meta.number_of_elements, sizeof(int64_t), f);\n    printf(\"Number of elements: %lu\\n\", meta.number_of_elements);\n\n    for (uint64_t i = 0; i \u003c meta.number_of_elements; i++) {\n        uint8_t *buff = (uint8_t*)malloc(sizes[i]);\n        fread(buff, sizes[i], 1, f);\n        data_t_read(data + i, buff);\n        printf(\"%lu. %s %s, age: %d, height: %d, weight: %d\\n\", i, data[i].name, data[i].surname, data[i].age, data[i].height, data[i].weight);\n        data_t_free(data[i]);\n        free(buff);\n    }\n    fclose(f);\n    free(sizes);\n    free(data);\n\n    return 0;\n}\n```\n\n## Limitation\nThis module is well-suited for handling flat data, though it requires more effort to store and retrieve data compared to simpler tools like Pickle. However, reading pickle-formatted data in C++ can be challenging, which is where this module proves advantageous. Pycerializer was initially developed as an ad-hoc solution for a Python prototyping project where the data output needed to be read in C++. In such scenarios, it performs effectively. Currently, the module supports a limited set of data types, but this can be easily extended. Contributions to enhance its functionality are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsusik%2Fpycerializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsusik%2Fpycerializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsusik%2Fpycerializer/lists"}