Closed neg3ntropy closed 4 years ago
@neg3ntropy Thanks for the request, it makes sense to me. Let me think about implementation details a bit and how the API should change before taking a stab at it.
I've got a WIP PR up that should address this in #469.
It adds a new method, create
for building ULID instances when you have both parts.
timestamp = time.time()
value = ulid.create(timestamp, ulid.MAX_RANDOMNESS)
I'm not sure if I like this more than using from_timestamp
and from_randomness
with optional kwargs for the other parts, was just trying to avoid more branching logic and handle the case where the caller has both parts of a ULID instead of just one. I'll think about this some more.
To do range selection on time with ULIDs one needs to generate values with the lowest/highest possible randomness.
While this is doable with some effort, I feel it should be offered by the API. For example: