Spaces:
Running
Running
Download core/__init__.py from iamfebin/algospaced-dsa: direct link, hf CLI and curl.
- Browser
- Download file 707 Bytes
-
https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/core/__init__.py
- Command line
-
hf download hf://spaces/iamfebin/algospaced-dsa/core/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/iamfebin/algospaced-dsa/resolve/main/core/__init__.py
707 Bytes
| """Core shared utilities and dependencies for AlgoSpaced.""" | |
| import uuid | |
| def uuid_str() -> str: | |
| """Generates a UUID string using Python 3.14's native uuid.uuid7() (RFC 9562). | |
| Falls back to uuid.uuid4() if running in pre-3.14 environments. | |
| """ | |
| uuid_func = getattr(uuid, "uuid7", uuid.uuid4) | |
| return str(uuid_func()) | |
| def uuid_hex_short(length: int = 8) -> str: | |
| """Generates a short hex identifier from a UUID (UUIDv7 in Python 3.14+, UUIDv4 fallback). | |
| Extracts from the random suffix to prevent collisions across sub-minute calls. | |
| """ | |
| if length <= 0: | |
| return "" | |
| uuid_func = getattr(uuid, "uuid7", uuid.uuid4) | |
| return uuid_func().hex[-min(length, 32) :] | |