Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
shpaker authored Jan 1, 2025
1 parent ab10e0d commit 67784ed
Showing 1 changed file with 46 additions and 11 deletions.
57 changes: 46 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,61 @@
[![PyPI](https://img.shields.io/pypi/v/epyxid.svg)](https://pypi.python.org/pypi/epyxid)
[![PyPI](https://img.shields.io/pypi/dm/epyxid.svg)](https://pypi.python.org/pypi/epyxid)

Fast globally unique sortable id generator.
Fast, globally unique, and sortable ID generator.

Python wrapper around Rust implementation of xid https://github.com/kazk/xid-rs
ePyXID is a Python wrapper around the Rust implementation of xid: [xid-rs](https://github.com/kazk/xid-rs). It provides a simple and efficient way to generate unique IDs that are sortable by creation time.

## Install
## Features

- **Globally Unique**: Each ID is unique across space and time.
- **Sortable**: IDs are sortable by their creation time.
- **Fast**: Implemented in Rust for maximum performance.

## Installation

Install ePyXID using pip:

```shell
pip install epyxid
```

## Usage
## Quick Start

Generate and use ePyXID in your Python projects:

```python
from epyxid import XID

xid: XID = XID()
print(xid)
# cnisffq7qo0qnbtbu5gg
print(bytes(xid))
# b'e\xe5\xc7\xbfG\xd6\x01\xab\xaf\xab\xf1a'
print(xid.time)
# 2024-03-04 16:08:15
# Create a new XID
xid = XID()

# Print the XID as a string
print(f"XID: {xid}")
# Example output: XID: cnisffq7qo0qnbtbu5gg

# Get the byte representation of the XID
print(f"Bytes: {bytes(xid)}")
# Example output: Bytes: b'e\xe5\xc7\xbfG\xd6\x01\xab\xaf\xab\xf1a'

# Access the creation time of the XID
print(f"Creation Time: {xid.time}")
# Example output: Creation Time: 2024-03-04 16:08:15

xid1 = XID()
xid2 = XID()

# Compare XIDs
print(f"XID1 < XID2: {xid1 < xid2}")

# Use XIDs in a set
xid_set = {xid1, xid2}
print(f"XID Set: {xid_set}")
```

## Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

## License

This project is licensed under the MIT License.

0 comments on commit 67784ed

Please sign in to comment.