mdomke / python-ulid

ULID implementation for Python
https://python-ulid.rtfd.io
MIT License
412 stars 19 forks source link

make use of time.clock_gettime_ns() #12

Closed socketpair closed 7 months ago

socketpair commented 1 year ago

It is faster and without floating point. Just time.clock_gettime_ns() // 1000000 to get milliseconds.

mdomke commented 1 year ago

@socketpair Feel free to create a pull-request 😄

musicinmybrain commented 9 months ago

This is a good idea. I’m not sure if it’s really meaningfully faster, but it does make sense to use an integer API when we want an integer. One caveat is that clock_gettime_ns is UNIX-only, while time_ns is portable, and should be just as good except that the former has the ability to specify a non-default clock. I’ll submit a PR to change the default-initialization method as suggested here.

socketpair commented 7 months ago

IS faster: https://github.com/python/cpython/issues/111482