python-ulid icon indicating copy to clipboard operation
python-ulid copied to clipboard

monotonic entropy for ULIDs created in the same ms?

Open itdaniher opened this issue 6 years ago • 2 comments

ULID spec now calls out entropy monotonicity for subsequent ULIDs generated in the same millisecond. It wasn't immediately clear to me how to approach that here, but I spent a few minutes looking at it. Seems like an API change might be required, or globals like I wound up trying for ulid2.

Bit of discussion at ahawker/ulid#306.

itdaniher avatar Jan 02 '19 22:01 itdaniher

Just found myself needing this exact feature - I want ULIDs created within the same ms to still sort after each other.

Looks like https://github.com/itsrainingmani/py-ulid has a version of this: https://github.com/itsrainingmani/py-ulid/blob/bd63902a1297d32b0a264601e20400a8ce20e926/ulid/ulid.py#L202-L268

simonw avatar May 27 '25 02:05 simonw

Here's the official spec for how this should work: https://github.com/ulid/spec/blob/master/README.md#monotonicity

simonw avatar May 27 '25 02:05 simonw

@mdomke can you please add support for this feature, itsrainingmani/py-ulid and ahawker/ulid already do, but personally I prefer your package since it's compatible with pydantic out of the box.

bassemkaroui avatar Aug 13 '25 21:08 bassemkaroui

Interesting that there still seems to be interest after no reaction for 6 years... But at least some new contributions have been merged, so maybe not all hope is lost if someone else wants to risk doing this work in vain.

reneleonhardt avatar Aug 14 '25 19:08 reneleonhardt

But at least some new contributions have been merged, so maybe not all hope is lost if someone else wants to risk doing this work in vain.

@reneleonhardt I'm not sure if I understand your concern. This library has seen steady development over the years, with many contributions merged successfully. As an open source project, I welcome contributions from anyone interested in this feature - and I'm happy to work with contributors to ensure their efforts aren't in vain. I can also try to find some time to implement this myself, but it hasn't been a priority so far.

mdomke avatar Aug 18 '25 10:08 mdomke

It's a good sign that some contributions have been merged, what I meant is that this literally is the feature request number 1 and no one knew for six years if such a contribution would be allowed, thank you for reacting 👍

reneleonhardt avatar Aug 18 '25 12:08 reneleonhardt

@reneleonhardt I'm a bit puzzled: Why would a contribution not be allowed? So far, every pull-request has been eventually accepted, but in this case nobody offered to contribute, and I didn't find the time to work on it myself.

This being said, I have implemented the requested functionality in 3.1.0

mdomke avatar Aug 18 '25 16:08 mdomke

You can never know in advance how maintainers react to contributions, I'm glad that this project embraces them!

Thank you for implementing it 🚀

reneleonhardt avatar Aug 19 '25 12:08 reneleonhardt

This being said, I have implemented the requested functionality in 3.1.0

Thank you so much, I've tested it and it works to perfection.

bassemkaroui avatar Aug 19 '25 16:08 bassemkaroui