{"id":16699310,"url":"https://github.com/ousttrue/tupleannot","last_synced_at":"2025-07-12T08:33:21.056Z","repository":{"id":136461180,"uuid":"190067462","full_name":"ousttrue/tupleannot","owner":"ousttrue","description":"binary format experiment","archived":false,"fork":false,"pushed_at":"2019-06-06T20:02:37.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T04:32:44.732Z","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/ousttrue.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-06-03T19:18:48.000Z","updated_at":"2019-07-09T11:23:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"85d1e6f4-2211-4467-930c-9d3737b9cdb7","html_url":"https://github.com/ousttrue/tupleannot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ousttrue/tupleannot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Ftupleannot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Ftupleannot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Ftupleannot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Ftupleannot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ousttrue","download_url":"https://codeload.github.com/ousttrue/tupleannot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ousttrue%2Ftupleannot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264962643,"owners_count":23689853,"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","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-12T18:06:34.949Z","updated_at":"2025-07-12T08:33:21.017Z","avatar_url":"https://github.com/ousttrue.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tupleannot\n\nbinary data annotation for static typing\n\n* Primitives\n  * Int8, 16, 32, 64\n  * UInt8, 16, 32, 64\n  * Float, Double\n* Collection\n  * Typed Array\n    * array length\n      * fixed\n      * lazy(length is stored in previous value)\n    * element length\n      * fixed\n      * variable(contain lazy length array)\n* Tuple\n* String\n\n## Usage\n\n### type definition\n\n```python\n# type definition\nclass Vec3(TypedTuple):\n    x: FloatLE\n    y: FloatLE\n    z: FloatLE\n\n# binary data\ndata = struct.pack('ffffffd', 1, 2, 3, 4, 5, 6, 7)\n\n# parse\nvec3, remain = Vec3[2].parse(data) # consume bytes\n\n# parsed\nself.assertEqual(1, vec3[0]['x'])\nself.assertEqual(2, vec3[0]['y'])\nself.assertEqual(3, vec3[0]['z'])\nself.assertEqual(4, vec3[1]['x'])\nself.assertEqual(5, vec3[1]['y'])\nself.assertEqual(6, vec3[1]['z'])\n```\n\n### lazy array length\n\n```python\nclass Val(TypedTuple):\n    length: UInt8\n    values: UInt32LE[-1] # determinate array length by relative value\n\ndata = struct.pack('\u003cB2I', 2, 1, 2)\n\nparsed, remain = Val.parse(data)\n```\n\n### variable element length\n\n```python\nclass Val(TypedTuple):\n    length: UInt8\n    values: Vec3[-1] # determinate array length by relative value\n\nclass VariableLengthArray(TypedTuple):\n    tuple_items: Val[2] # item length is variable\n```\n\n### string\n\n```python\ndata = '文字列'.encode('cp932')\nparsed, remain = String[6, 'cp932'].parse(data)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fousttrue%2Ftupleannot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fousttrue%2Ftupleannot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fousttrue%2Ftupleannot/lists"}