{"id":21569384,"url":"https://github.com/aweirddev/protonbites","last_synced_at":"2026-04-29T19:33:14.351Z","repository":{"id":240955682,"uuid":"803799389","full_name":"AWeirdDev/protonbites","owner":"AWeirdDev","description":"Most sane way to store JSON data.","archived":false,"fork":false,"pushed_at":"2024-05-26T01:48:04.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T09:38:07.608Z","etag":null,"topics":["bytes","dataclass","decoder","encoder","json","mr-penguin","protobuf","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/protonbites","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AWeirdDev.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,"zenodo":null}},"created_at":"2024-05-21T12:07:21.000Z","updated_at":"2024-05-26T01:48:07.000Z","dependencies_parsed_at":"2024-05-21T16:48:03.256Z","dependency_job_id":"ea979ef2-8c8c-410b-989e-5b3c7e98dc56","html_url":"https://github.com/AWeirdDev/protonbites","commit_stats":null,"previous_names":["aweirddev/protonbites"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AWeirdDev/protonbites","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fprotonbites","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fprotonbites/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fprotonbites/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fprotonbites/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AWeirdDev","download_url":"https://codeload.github.com/AWeirdDev/protonbites/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fprotonbites/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32441112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T18:12:22.909Z","status":"ssl_error","status_checked_at":"2026-04-29T18:11:33.322Z","response_time":110,"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":["bytes","dataclass","decoder","encoder","json","mr-penguin","protobuf","python"],"created_at":"2024-11-24T11:09:19.117Z","updated_at":"2026-04-29T19:33:14.337Z","avatar_url":"https://github.com/AWeirdDev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# protonbites \u003ckbd\u003e🧪 EXPR1\u003c/kbd\u003e\nMost sane way to store JSON data. Simple, light, strongly-typed and secure. (Probably, overall)\n\n**Step 1.** Create a dataclass.\n\n```python\nfrom dataclasses import dataclass\n\n@dataclass\nclass Person:\n    name: str\n    age: int\n```\n\n\u003e For floats and ints, you can use `typing.Annotated[int, '\u003cdtype\u003e']` where `\u003cdtype\u003e` is the desired datatype.\n\u003e Below are the avilable dtypes:\n\u003e \n\u003e **ints**\n\u003e - int8 / uint8\n\u003e - int16 / uint16\n\u003e - int32 / uint32\n\u003e - int64 / uint64\n\u003e \n\u003e **floats**\n\u003e - float32\n\u003e - float64\n\n\n**Step 2.** Create a schema from the dataclass.\n\n```python\nfrom protonbites import get_schema\n\nschema = get_schema(Person)\n```\n\n**Step 3.** Use the schema to encode/decode data.\n\n```python\n# Init a new dataclass\nperson = Person(name=\"Jesse Pinkman\", age=28)\n\nencoded = schema.encode(person)\ndecoded = schema.decode(encoded)\n\nassert isinstance(decoded, Person)\n```\n\n## API Documentation \u003ckbd\u003eincomplete\u003c/kbd\u003e\n\nOopsy daisy.\n\n### \u003ckbd\u003edef\u003c/kbd\u003e encode\n\n```python\ndef encode(\n    obj: PythonBackendDataTypes, \n    /, \n    *,\n    force_keep_str: bool = False\n) -\u003e bytes\n```\n\nEncode data to a proton.\n\n**Args**:\n- obj (`PythonBackendDataTypes`): Object.\n- force_keep_str (`bool`): Force keep the string? Usually, when the expected text length is more than 102 characters, we use `gzip` to compress the text data. If you wish to keep the string, set this to `True`.\n\n**Simple Example:**\n```python\nencode({\n    \"name\": \"Mr. Penguin\",\n    \"tags\": [\"depressed\"],\n    \"friends\": [\n        {\n            \"name\": \"Fernando Miguel\",\n            \"tags\": [\"dancing\", \"noot\"]\n        }\n    ]\n})\n# =\u003e b\"\\x01\\x0f'Mr. Penguin'\\x11\\x03\\x0f'depressed'\\x11\\x04\\x11\\x03\\x01\\x0f'Fernando Miguel'\\x11\\x03\\x0f'dancing'\\x11\\x0f'noot'\\x11\\x04\\x11\\x02\\x11\\x04\\x11\\x02\"\n\nencode({ \"text\": \"what the fish \" * 9_999 })\n# =\u003e b'\\x01\\x0f1f8b0800a6ed516602ffe…bf2c1f2a24c7aad4220200\\x11\\x02'\n```\n\n**Example using custom ints and floats:**\n```python\nfrom protonbites import uint8, float32\n\nencode({\n    \"a\": uint8(10),\n    \"b\": float32(10.98535)\n})\n```\n\n\u003cbr /\u003e\n\n### \u003ckbd\u003edef\u003c/kbd\u003e decode\n\n```python\ndef decode(__c: bytes, /) -\u003e PythonBackendTypes\n```\n\nDecode the data.\n\n**Args:**\n- \\_\\_c: The encoded data.\n\n**Example:**\n```python\na = decode(b\"\\x01…\\x02\")\n# =\u003e [ …, …, … ]\n\nreveal_type(a)  # PythonBackendDataTypes (type_checking)\n\n# To ensure the decoded data is the entrypoint\nb = decoded_safely(a)\nreveal_type(b)  # list (type_checking)\n```\n\n\u003cbr /\u003e\n\n### \u003ckbd\u003edef\u003c/kbd\u003e get_schema\n\n```python\ndef get_schema(__dc: type[T], /) -\u003e Schema[T]\n```\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003ccode\u003ewhere T:\u003c/code\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n```haskell\nwhere T: DataclassProtocol\n```\n\n```python\nT = TypeVar('T', bound=DataclassProtocol)\n# get_schema(__dc: type[T@get_schema], /) -\u003e Schema[T@get_schema]\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n**Args:**\n- \\_\\_dc: The dataclass.\n\n```python\n@dataclass\nclass Person:\n    name: str\n    age: int\n\nschema = get_schema()\nschema.encode(Person(name=\"Jesse Pinkman\", age=28))\n```\n\n\u003cbr /\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWere you looking for Mr. Penguin?\u003c/summary\u003e\n\u003cp\u003e\n\n\u003cimg src=\"https://github.com/AWeirdDev/protonbites/assets/90096971/26303b62-3ffe-4665-ab2b-36f331ec2f04\" alt=\"What you're looking for is here\" align=\"left\" /\u003e\n\u003cp\u003eI'm standing in a void. No light. No sound. And as I stand there... In front of me, a penguin manifests. He merely stands. Observing. But I. I am filled with dread. I dare think it, but not say it. Are you the embodiment of my end? His gaze, so vacant, pierces my very soul. Then, from the all-encompassing abyss itself, the noots of a hundred penguins billow out. The noots coalesce, forming bodies. But from those bodies, arise not life, but... flames. Their joyful noots mutate into agonized screams. Suddenly, they're engulfed by the void. Yet, the most haunting realization? In their fleeting, fiery visages, I glimpse my own reflection.\u003c/p\u003e\u003cbr /\u003e\u003cbr /\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n***\n\n(c) 2024 AWeirdDev\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faweirddev%2Fprotonbites","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faweirddev%2Fprotonbites","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faweirddev%2Fprotonbites/lists"}