
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
V4 UUIDs are often used as primary keys or as part of database indexes. However, their random and non-sequential nature can cause locality and performance issues.
This Python 3 package mitigates these issues by using encoding a UNIX
timestamp in the first 6 bytes of the UUID, and filling the remaining bytes
with random data. The uuid0.UUID
class inherits from the standard
uuid.UUID
class so it's safe to use all the usual properties (hex, int,
bytes, etc.)
The package also contains uuid0.django
which provides Django form and
model fields based on the UUID0 type, as well as an abstract UUID0Model
.
This package is in alpha status, use at your own risk.
Install by running::
pip install uuid0
Example usage::
import uuid0
uuid0.generate() UUID('0dc7ef03-c534-d288-67b7-34cf4dfa9350')
x = uuid0.UUID('{0b7dd8d0-7e40-8360-9322-4a361d7b573f}')
str(x.datetime) '2010-01-15 00:00:36'
str(x) '0b7dd8d0-7e40-8360-9322-4a361d7b573f'
x.base62 'LgQWTxkOpLyTaEuRAav9D'
uuid0.UUID(base62=x.base62) UUID('0b7dd8d0-7e40-8360-9322-4a361d7b573f')
x.bytes b'\x0b}\xd8\xd0~@\x83`\x93"J6\x1d{W?'
uuid0.UUID(bytes=x.bytes) UUID('0b7dd8d0-7e40-8360-9322-4a361d7b573f')
Collisions are a concern, of course, but only if you are generating really large amounts of UUIDs in a short timespan.
By default, uuid0 only uses 6 bytes to encode the time and does not encode any version bits, leaving 10 bytes (80 bits) of random data.
The probability of collision is near zero for most use cases since for each
1/10000s period, there are 2\ :sup:80
possible UUIDs.
Generating a UUID0 is slower than generating a UUID v4, but faster than a UUID v1.
Below are results for 500k iterations on an i7-6700HQ and Python 3.6.2
(generated using the benchmarks/generate.py
script):
================= ========= ========= ======== method it/s ?s/it % slower ================= ========= ========= ======== uuid.uuid4() 453043 2.207 0.0% uuid0.generate() 311184 3.214 31.31% uuid.uuid1() 230163 4.345 49.2% ================= ========= ========= ========
In terms of database performance, indexes are approximately 18% smaller and
inserts about 23% faster on PostgreSQL with a uuid
type column, but YMMV
depending on your use case.
This project is licensed under the MIT License. See the LICENSE
file for
details.
FAQs
A library to make better timestamped UUIDs for databases and web apps
We found that uuid0 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.