Skip to content

Commit

Permalink
add implementation table
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne committed Jul 15, 2024
1 parent 40ae9be commit e4ddf68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
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

0 comments on commit e4ddf68

Please sign in to comment.