{"id":50485096,"url":"https://github.com/partiallywritten/humans-formatter-py","last_synced_at":"2026-06-01T21:30:24.999Z","repository":{"id":349093602,"uuid":"1197650703","full_name":"partiallywritten/humans-formatter-py","owner":"partiallywritten","description":"Zig implementation of humans-formatter python extension","archived":false,"fork":false,"pushed_at":"2026-05-05T07:52:54.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-05T09:35:09.381Z","etag":null,"topics":["python-extension","zig","zig-python-bindings"],"latest_commit_sha":null,"homepage":"https://codeberg.org/partiallywritten/humans-formatter-py","language":"Zig","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/partiallywritten.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-31T19:00:43.000Z","updated_at":"2026-05-05T07:52:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/partiallywritten/humans-formatter-py","commit_stats":null,"previous_names":["partiallywritten/humans-formatter-zig","partiallywritten/humans-formatter-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/partiallywritten/humans-formatter-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/partiallywritten%2Fhumans-formatter-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/partiallywritten%2Fhumans-formatter-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/partiallywritten%2Fhumans-formatter-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/partiallywritten%2Fhumans-formatter-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/partiallywritten","download_url":"https://codeload.github.com/partiallywritten/humans-formatter-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/partiallywritten%2Fhumans-formatter-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33795112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"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":["python-extension","zig","zig-python-bindings"],"created_at":"2026-06-01T21:30:24.112Z","updated_at":"2026-06-01T21:30:24.993Z","avatar_url":"https://github.com/partiallywritten.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# humans-formatter-py\nRe-implementation of my pypi library, [humans-formatter](https://pypi.org/project/humans-formatter/) in zig.\n\n\n### Usage\n```py\nimport humans\n\n# time formatting\n# time(ms: int, compound: bool = True, round: bool = False)\n# \t- Format milliseconds into human readable form. Use only one argument except 'ms' at a time\nprint(humans.time(\u003ctime-in-ms\u003e)\n\n\n# byte formatting\n# bytes(size: int)\n# \t- Convert bytes into human readable KiB/MiB/etc.\nprint(humans.bytes(\u003cbytes\u003e)\n\n\n# see docs\nprint(humans.__doc__)\nprint(humans.time.__doc__)\nprint(humans.bytes.__doc__)\n```\n\n\n### Build it\n\n\u003e [!IMPORTANT]\n\u003e This extension requires,\n\u003e   - python 3.13 or newer as it uses [fast calls](https://docs.python.org/3/c-api/structures.html#c.METH_FASTCALL) [^1]\n\u003e   - zig 0.15.2 (or newer, not tested) as it uses `std.Io.Writer` (see [Writergate update](https://ziglang.org/download/0.15.1/release-notes.html#Writergate))\n\n```sh\nzig build-lib -dynamic -O ReleaseFast -I /usr/include/python\u003cx.xx\u003e -femit-bin=\u003cpath\u003e -lc wrapper.zig\n```\nReplace placeholders with\n  - `python\u003cx.xx\u003e` - Your python version (`python --version`). ex: `python3.14`\n  - `\u003cpath\u003e` - Path to where the `*.so` file needs to be created. ex: `tests/humans.so`\n\nOnce you get your `*.so` file, you can just import it in python using `import \u003cfilename\u003e` (replace \u003cfilename\u003e with whatever the name of your .so file without the extension); Assuming they are both in the same directory\n\n\n### Performance results\nUp to **6.5x** speed boost on `humans.time()` and Up to **6.4x** speed boost on `humans.bytes()` compared their python counterparts\n\u003cdetails\u003e\n  \u003csummary\u003eClick to See detailed results\u003c/summary\u003e\n  \n  ```\n======== Benchmark ========\n\n[humans.time()]\n   Runs:        5\n   Iterations:  3,000,000\n   Mean total:  0.329832 sec\n   Best total:  0.327457 sec\n   Std dev:     0.003686 sec\n   Mean/op:     109.94 ns\n   Best/op:     109.15 ns\n\n[humans.bytes()]\n   Runs:        5\n   Iterations:  3,000,000\n   Mean total:  0.374867 sec\n   Best total:  0.371739 sec\n   Std dev:     0.003231 sec\n   Mean/op:     124.96 ns\n   Best/op:     123.91 ns\n\n[origin.time()]\n   Runs:        5\n   Iterations:  3,000,000\n   Mean total:  2.346812 sec\n   Best total:  2.323678 sec\n   Std dev:     0.016030 sec\n   Mean/op:     782.27 ns\n   Best/op:     774.56 ns\n\n[origin.bytes()]\n   Runs:        5\n   Iterations:  3,000,000\n   Mean total:  2.641040 sec\n   Best total:  2.629541 sec\n   Std dev:     0.012963 sec\n   Mean/op:     880.35 ns\n   Best/op:     876.51 ns\n\n[Sample Outputs]\n   humans.time: 1h 1m 1s\n   humans.bytes: 1.00 GiB\n  ```\n\u003c/details\u003e\n\nsee [bench.py](tests/bench.py) and [python implementation](tests/origin.py) for more info.\nBoth are optimized and implementations of the same logic\n\n\n[^1]: It can be compiled on older versions as long as the header file contain necessary signatures and macros\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpartiallywritten%2Fhumans-formatter-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpartiallywritten%2Fhumans-formatter-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpartiallywritten%2Fhumans-formatter-py/lists"}