Metadata-Version: 2.4
Name: lastuuid
Version: 0.2.1
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: furo>=2024.5.6 ; extra == 'docs'
Requires-Dist: linkify-it-py>=2.0.3,<3 ; extra == 'docs'
Requires-Dist: myst-parser>=3.0.0,<4 ; python_full_version < '3.10' and extra == 'docs'
Requires-Dist: myst-parser>=4.0.0,<5 ; python_full_version >= '3.10' and extra == 'docs'
Requires-Dist: sphinx>=7.0.1,<8 ; extra == 'docs'
Requires-Dist: sphinx-autodoc2>=0.5.0,<1 ; extra == 'docs'
Provides-Extra: docs
Summary: Fast UUIDv7 Compatible with standard library type, and utils.
Keywords: uuid,UUIDv7
Author: Guillaume Gauvrit <guillaume@gauvr.it>
Author-email: Guillaume Gauvrit <guillaume@gauvr.it>
License: MIT License
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/mardiros/lastuuid
Project-URL: Documentation, https://mardiros.github.io/lastuuid/
Project-URL: Repository, https://github.com/mardiros/lastuuid.git
Project-URL: Issues, https://github.com/mardiros/lastuuid/issues
Project-URL: Changelog, https://mardiros.github.io/lastuuid/changelog.html

# lastuuid - yet another uuid library

[![Documentation](https://github.com/mardiros/lastuuid/actions/workflows/publish-doc.yml/badge.svg)](https://mardiros.github.io/lastuuid/)
[![Continuous Integration](https://github.com/mardiros/lastuuid/actions/workflows/tests.yml/badge.svg)](https://github.com/mardiros/lastuuid/actions/workflows/tests.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/8e7293fabe7508b2ec6c/maintainability)](https://codeclimate.com/github/mardiros/lastuuid/maintainability)

UUID type is awesome, but, at the moment, the UUID type in the standard library
does not support the uuid7 format.

You may find plenty of library that implement uuid7, but they have downside,
such has ignoring pull request to fix issues, or not compatible with Pydantic.

```{note}
lastuuid is a developer joke based on the nature of UUIDv7,

where the most recently generated UUID is always the last one when sorted.
```

## Usage

### UUID7

```python
>>> from lastuuid import uuid7
>>> uuid7()
UUID('019316cc-f99a-77b3-89d5-ed8c3cf1f50e')
```

There is no parameter here, the uuid is generated from the current time.

The implementation of uuid7 algorithm is made in the uuid7 rust crate.

#### Pydantic

This lib has been created because all the other library that implement uuid7
create there own UUID type, so its not easy to use with pydantic.

```python
from uuid import UUID
from pydantic import BaseModel, Field

from lastuuid import uuid7


class Dummy(BaseModel):
    id: UUID = Field(default_factory=uuid7)

```

#### Performance

On my machine the uuid7 is as fast (or slow) as the native uuid4.

```bash
$ python -m timeit "from lastuuid import uuid7; uuid7()"
200000 loops, best of 5: 1.8 usec per loop

$ python -m timeit "from uuid import uuid4; uuid4()"
200000 loops, best of 5: 1.82 usec per loop
```

### Read More

There are other usefull function in the library that cab be found in the
[API documentation](https://mardiros.github.io/lastuuid/).

https://mardiros.github.io/lastuuid/

