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

make use of time.clock_gettime_ns()

Open socketpair opened this issue 2 years ago • 2 comments

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

socketpair avatar Oct 27 '23 23:10 socketpair

@socketpair Feel free to create a pull-request 😄

mdomke avatar Nov 01 '23 20:11 mdomke

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.

musicinmybrain avatar Jan 31 '24 19:01 musicinmybrain

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

socketpair avatar Mar 19 '24 11:03 socketpair