Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make use of time.clock_gettime_ns() #12

Closed
socketpair opened this issue Oct 27, 2023 · 3 comments · Fixed by #16
Closed

make use of time.clock_gettime_ns() #12

socketpair opened this issue Oct 27, 2023 · 3 comments · Fixed by #16

Comments

@socketpair
Copy link

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

@mdomke
Copy link
Owner

mdomke commented Nov 1, 2023

@socketpair Feel free to create a pull-request 😄

musicinmybrain added a commit to musicinmybrain/python-ulid that referenced this issue Jan 31, 2024
@musicinmybrain
Copy link
Contributor

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
Copy link
Author

socketpair commented Mar 19, 2024

IS faster: python/cpython#111482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants