{"id":18016404,"url":"https://github.com/saresend/ksuid","last_synced_at":"2025-03-26T18:32:08.459Z","repository":{"id":50357087,"uuid":"94033109","full_name":"saresend/KSUID","owner":"saresend","description":"Sortable UIDs in Python","archived":false,"fork":false,"pushed_at":"2018-11-21T05:51:23.000Z","size":21,"stargazers_count":97,"open_issues_count":3,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T06:41:50.267Z","etag":null,"topics":["datetime","python3","sortable","uid"],"latest_commit_sha":null,"homepage":"","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/saresend.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":"2017-06-11T21:33:54.000Z","updated_at":"2024-10-08T15:01:50.000Z","dependencies_parsed_at":"2022-09-02T19:50:24.864Z","dependency_job_id":null,"html_url":"https://github.com/saresend/KSUID","commit_stats":null,"previous_names":["samuel-resendez/ksuid"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saresend%2FKSUID","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saresend%2FKSUID/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saresend%2FKSUID/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saresend%2FKSUID/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saresend","download_url":"https://codeload.github.com/saresend/KSUID/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245712974,"owners_count":20660327,"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":["datetime","python3","sortable","uid"],"created_at":"2024-10-30T04:17:50.189Z","updated_at":"2025-03-26T18:32:08.171Z","avatar_url":"https://github.com/saresend.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KSUID\r\n\r\n## What is a ksuid?\r\n\r\nA ksuid is a K sorted UID. In other words, a KSUID also stores a date component, so that ksuids can be approximately \r\nsorted based on the time they were created. \r\n\r\n\r\n## Quick overview\r\n\r\nA ksuid is composed of two components: the date time, which is stored as the first four bytes of the uid, along with a randomly\r\ngenerated payload of 16, for a total of 20 bytes. \r\n\r\n## A few advantages\r\n\r\n1. The potential number of IDs available is greater than even that of UUID4 (which accepts 122 bits). KSUIDs are about 64 times larger than that. Coupled with the timestamp, the likelihood of getting 2 identical Ksuids is exceedingly low;\r\n2. Enables sorting of UIDs in a sensible fashion, based on their timestamp;\r\n3. Supports Base62 encoding - can be serialized to Base62 and vice versa\r\n\r\n\r\n## Installation\r\n\r\nThe ksuid library can be installed via pip:\r\n\r\n```pip install ksuid```\r\n\r\n** Note: currently only tested for Python 3.x \u003c/h3\u003e**\r\n## Sample Usage:\r\n\r\n```python\r\n\u003e\u003e\u003e from ksuid import ksuid\r\n\u003e\u003e\u003e x = ksuid()\r\n\u003e\u003e\u003e print(x) \r\n\u003e\u003e\u003e '05cbd3454355fe1e1f11c85bb2c1e3e2f7c93525 '\r\n\u003e\u003e\u003e x.getTimestamp()\r\n\u003e\u003e\u003e 1497243973\r\n\u003e\u003e\u003e x.getDatetime() \r\n\u003e\u003e\u003e datetime.date(2017, 6, 11)\r\n\u003e\u003e\u003e x \r\n\u003e\u003e\u003e \u003cksuid.ksuid object at 0x100784a90\u003e \r\n\u003e\u003e\u003e x.bytes()\r\n\u003e\u003e\u003e b'\\x05\\xcb\\xd7\\xd0\\xc6\\xcb\\x98i\\xeb\\xa0}\\xfa\\x0f\\x87\\xf1\\xf1\\xe8\\xa1\\x83\\x9e'\r\n```\r\n\r\n## Base62 support\r\n\r\n```python\r\n\u003e\u003e\u003e import ksuid\r\n\u003e\u003e\u003e uid = ksuid.ksuid()\r\n\u003e\u003e\u003e print(uid)\r\n\u003e\u003e\u003e '0607ac1e7955e3d6a5da87c8dae2e1825c8ddfc9'\r\n\u003e\u003e\u003e v = uid.toBase62()\r\n\u003e\u003e\u003e print(v)\r\n\u003e\u003e\u003e 'rLIliIsDsLNj1b4tN1T3TZGC1B'\r\n```\r\n\r\n## Serialization to bytes support\r\n\r\n```python\r\n\u003e\u003e\u003e import ksuid\r\n\u003e\u003e\u003e uid = ksuid.ksuid()\r\n\u003e\u003e\u003e print(uid)\r\n\u003e\u003e\u003e '0607ac7351a48bb5e2f63b68094e465010496ff6'\r\n\u003e\u003e\u003e v = uid.toBytes()\r\n\u003e\u003e\u003e print(v)\r\n\u003e\u003e\u003e b'\\x06\\x07\\xacsQ\\xa4\\x8b\\xb5\\xe2\\xf6;h\\tNFP\\x10Io\\xf6'\r\n```\r\n\r\n## Developing\r\n\r\nFirst of all you need `make` utility for a little bit comfortable usage.\r\n\r\nYou can execute `make help` to view all available commands.\r\n\r\nPlease, run `make` to install virtual environment for testing and development.\r\n\r\nSupported commands:\r\n\r\n* `make` - create virtual env and setup dependencies;\r\n* `make tests` - run tests;\r\n* `make coverage` - run tests with coverage report;\r\n* `make lint` - check linting;\r\n* `make flake8` - alias for `make lint`\r\n* `make clean` - remove more or less everything created by make\r\n\r\n## Credit, where credit is due\r\n\r\nThis library is largely inspired by the go version, found here:\r\nhttps://github.com/segmentio/ksuid\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaresend%2Fksuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaresend%2Fksuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaresend%2Fksuid/lists"}