-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-110850: Add PyTime_TimeUnchecked() function #115973
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
Conversation
Add functions: * PyTime_MonotonicUnchecked() * PyTime_PerfCounterUnchecked() * PyTime_TimeUnchecked() Python now fails with a fatal error at startup if reading the system clock, the monotonic clock or the perf counter clock fails. Add py_perf_counter() function to factorize code.
See discussion capi-workgroup/decisions#8 about this API. |
OK, I'll repeat my questions here, too.
|
No function can be called before init/after init, except of these few functions listed there: https://docs.python.org/dev/c-api/init.html
Convenient int64_t format using Unix epoch 1970 in all platforms. Examples:
|
Similar for holding the GIL, and in my mind, doesn't need GIL and doesn't need the runtime initialized are the same set of functions. I'm not happy about another bit to track in the upcoming list of all Python API.
I know what it does; I'm asking why. Do we know about a use case that needs this, and can't GIL for exception-based error handling? I also know Cython wraps and re-exports the private API. I'm asking why it's needed. (If we just need to keep Cython going, we can add back the underscored versions, or add these as
And when we add a sixth one, we might need to increase the set of errors the |
The issue was created for Cython. I cannot check right now how people use Cython. |
The Python C API already has many functions which don't need to hold the GIL. Check fileutils.h functions. |
@scoder: You may reply to the Cython question. |
It's convenient. It gives the same results as Python's If you hold the GIL, you can probably (often) afford to keep a reference to |
OK! There are three functions in two
None of these are documented to not require the GIL. If they work without the GIL in practice, I consider that an accident of the implementation. There is also Thanks for the use cases. I get that Python exposes the “best” implementation, across platforms, but it still seems to me that Python-style error handling is an appropriate price for that, and But now I can see myself being convinced.
|
Oh I forgot that most fileutils.h functions are private. It's a good thing 😁
You need more includes to access all functions.
The basic gettimeofday() is not provided by time.h. time() is fine if you don't need better resolution than 1 second. Here we are talking about nanoseconds. See PEP 564 and PEP 418 for the rationale. |
Add functions:
Python now fails with a fatal error at startup if reading the system clock, the monotonic clock or the perf counter clock fails.
Add py_perf_counter() function to factorize code.
📚 Documentation preview 📚: https://cpython-previews--115973.org.readthedocs.build/