Skip to content

gh-155496: Use Argument Clinic for more functions in the time module - #155513

Open
serhiy-storchaka wants to merge 7 commits into
python:mainfrom
serhiy-storchaka:time-clinic
Open

gh-155496: Use Argument Clinic for more functions in the time module#155513
serhiy-storchaka wants to merge 7 commits into
python:mainfrom
serhiy-storchaka:time-clinic

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Convert all functions of the time module, except strftime() and strptime().
The docstring of strftime() is composed with the STRFTIME_FORMAT_CODES macro shared with strptime(), which Argument Clinic cannot express, and strptime() only forwards its arguments to _strptime._strptime_time().

time(), monotonic(), perf_counter(), process_time() and thread_time() now use the "double" return converter, which makes the _PyFloat_FromPyTime() helper redundant.

It needs a builtin function without a signature, but time.ctime() now
has one.
Any builtin function can get a signature, therefore the test uses the
function which exists for testing the lack of it.

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure that the parameters match what is documented.

Comment thread Modules/timemodule.c
Comment thread Modules/timemodule.c
Comment thread Modules/timemodule.c Outdated
Comment thread Modules/timemodule.c
Comment thread Modules/timemodule.c Outdated
Comment thread Modules/timemodule.c Outdated
Comment thread Modules/timemodule.c
Restore the default of time.asctime() as NULL, so that passing None
raises a TypeError as before, and fix the docstring of time.ctime()
and the comment for parse_time_t_arg().

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little, seems fine overall. Also, since we're adding signatures for some functions I think it can get a blurb.

Comment thread Modules/timemodule.c Outdated
Restore the link between the local timezone and the value stored in
os.environ['TZ'], which was lost when the docstring was split into a
summary line and a body.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StanFromIreland StanFromIreland changed the title gh-155496: Use Argument Clinic for more functions of the time module gh-155496: Use Argument Clinic for more functions in the time module Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants