Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add implementation table #9

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ with psycopg.connect("postgresql://...") as conn:
print(res) # user_2accvpp5guht4dts56je5a
```

## Table of contents
## Demo
You can give it a spin at [upid.rdrn.me](https://upid.rdrn.me/).

## Implementations

If you don't have time for ASCII art, you can skip to the good stuff:
* [Specification](#specification)
* [Python implementation](#python-implementation)
* [Rust implementation](#rust-implementation)
* [Postgres extension](#postgres-extension)
| Language | Link |
| -------- | ------------------------------------------------------- |
| Python | [in this repo (scroll down)](#python-implementation) |
| Postgres | [in this repo (scroll down)](#postgres-extension) |
| Rust | [in this repo (scroll down)](#rust-implementation) |
| TypeScript | [carderne/upid-ts](https://github.com/carderne/upid-ts) |

## Specification
Key changes relative to ULID:
Expand Down
4 changes: 2 additions & 2 deletions py/upid/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def from_prefix_and_datetime(cls: type[Self], prefix: str, datetime: dt.datetime
@classmethod
def from_prefix_and_milliseconds(cls: type[Self], prefix: str, milliseconds: int) -> Self:
"""
Create a new `UPID` from a `prefix`, using the supplied `timestamp`.
Create a new `UPID` from a `prefix`, using the supplied `milliseconds`.

`milliseconds` must be an int in milliseconds since the epoch.

The timestamp is converted to 6 bytes, but we drop 1 byte, resulting
in a time precision of about 100 milliseconds
in a time precision of about 256 milliseconds

The prefix is padded with 'z' characters (if too short) and
trimmed to 4 characters (if too long). Supply a prefix of exactly
Expand Down