mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-112919: Speed-up datetime, date and time.replace() (GH-112921)
Use argument clinic and call new_* functions directly. This speeds up these functions 6x to 7.5x when calling with keyword arguments.
This commit is contained in:
parent
4287e8608b
commit
1f515e8a10
7 changed files with 479 additions and 99 deletions
|
|
@ -876,6 +876,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(d));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(data));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(database));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(day));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(decode));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(decoder));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(default));
|
||||
|
|
@ -945,6 +946,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fix_imports));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(flags));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(flush));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fold));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(follow_symlinks));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(format));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(from_param));
|
||||
|
|
@ -975,6 +977,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(headers));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(hi));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(hook));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(hour));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(id));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ident));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(identity_hint));
|
||||
|
|
@ -1059,11 +1062,14 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(metaclass));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(metadata));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(method));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(microsecond));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(minute));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mod));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mode));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(module));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(module_globals));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(modules));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(month));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mro));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(msg));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(mycmp));
|
||||
|
|
@ -1168,6 +1174,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(salt));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(sched_priority));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(scheduler));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(second));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(seek));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(seekable));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(selectors));
|
||||
|
|
@ -1244,6 +1251,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
|
|||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(type));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(type_params));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tz));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tzinfo));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tzname));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(uid));
|
||||
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(unlink));
|
||||
|
|
|
|||
|
|
@ -365,6 +365,7 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(d)
|
||||
STRUCT_FOR_ID(data)
|
||||
STRUCT_FOR_ID(database)
|
||||
STRUCT_FOR_ID(day)
|
||||
STRUCT_FOR_ID(decode)
|
||||
STRUCT_FOR_ID(decoder)
|
||||
STRUCT_FOR_ID(default)
|
||||
|
|
@ -434,6 +435,7 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(fix_imports)
|
||||
STRUCT_FOR_ID(flags)
|
||||
STRUCT_FOR_ID(flush)
|
||||
STRUCT_FOR_ID(fold)
|
||||
STRUCT_FOR_ID(follow_symlinks)
|
||||
STRUCT_FOR_ID(format)
|
||||
STRUCT_FOR_ID(from_param)
|
||||
|
|
@ -464,6 +466,7 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(headers)
|
||||
STRUCT_FOR_ID(hi)
|
||||
STRUCT_FOR_ID(hook)
|
||||
STRUCT_FOR_ID(hour)
|
||||
STRUCT_FOR_ID(id)
|
||||
STRUCT_FOR_ID(ident)
|
||||
STRUCT_FOR_ID(identity_hint)
|
||||
|
|
@ -548,11 +551,14 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(metaclass)
|
||||
STRUCT_FOR_ID(metadata)
|
||||
STRUCT_FOR_ID(method)
|
||||
STRUCT_FOR_ID(microsecond)
|
||||
STRUCT_FOR_ID(minute)
|
||||
STRUCT_FOR_ID(mod)
|
||||
STRUCT_FOR_ID(mode)
|
||||
STRUCT_FOR_ID(module)
|
||||
STRUCT_FOR_ID(module_globals)
|
||||
STRUCT_FOR_ID(modules)
|
||||
STRUCT_FOR_ID(month)
|
||||
STRUCT_FOR_ID(mro)
|
||||
STRUCT_FOR_ID(msg)
|
||||
STRUCT_FOR_ID(mycmp)
|
||||
|
|
@ -657,6 +663,7 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(salt)
|
||||
STRUCT_FOR_ID(sched_priority)
|
||||
STRUCT_FOR_ID(scheduler)
|
||||
STRUCT_FOR_ID(second)
|
||||
STRUCT_FOR_ID(seek)
|
||||
STRUCT_FOR_ID(seekable)
|
||||
STRUCT_FOR_ID(selectors)
|
||||
|
|
@ -733,6 +740,7 @@ struct _Py_global_strings {
|
|||
STRUCT_FOR_ID(type)
|
||||
STRUCT_FOR_ID(type_params)
|
||||
STRUCT_FOR_ID(tz)
|
||||
STRUCT_FOR_ID(tzinfo)
|
||||
STRUCT_FOR_ID(tzname)
|
||||
STRUCT_FOR_ID(uid)
|
||||
STRUCT_FOR_ID(unlink)
|
||||
|
|
|
|||
8
Include/internal/pycore_runtime_init_generated.h
generated
8
Include/internal/pycore_runtime_init_generated.h
generated
|
|
@ -874,6 +874,7 @@ extern "C" {
|
|||
INIT_ID(d), \
|
||||
INIT_ID(data), \
|
||||
INIT_ID(database), \
|
||||
INIT_ID(day), \
|
||||
INIT_ID(decode), \
|
||||
INIT_ID(decoder), \
|
||||
INIT_ID(default), \
|
||||
|
|
@ -943,6 +944,7 @@ extern "C" {
|
|||
INIT_ID(fix_imports), \
|
||||
INIT_ID(flags), \
|
||||
INIT_ID(flush), \
|
||||
INIT_ID(fold), \
|
||||
INIT_ID(follow_symlinks), \
|
||||
INIT_ID(format), \
|
||||
INIT_ID(from_param), \
|
||||
|
|
@ -973,6 +975,7 @@ extern "C" {
|
|||
INIT_ID(headers), \
|
||||
INIT_ID(hi), \
|
||||
INIT_ID(hook), \
|
||||
INIT_ID(hour), \
|
||||
INIT_ID(id), \
|
||||
INIT_ID(ident), \
|
||||
INIT_ID(identity_hint), \
|
||||
|
|
@ -1057,11 +1060,14 @@ extern "C" {
|
|||
INIT_ID(metaclass), \
|
||||
INIT_ID(metadata), \
|
||||
INIT_ID(method), \
|
||||
INIT_ID(microsecond), \
|
||||
INIT_ID(minute), \
|
||||
INIT_ID(mod), \
|
||||
INIT_ID(mode), \
|
||||
INIT_ID(module), \
|
||||
INIT_ID(module_globals), \
|
||||
INIT_ID(modules), \
|
||||
INIT_ID(month), \
|
||||
INIT_ID(mro), \
|
||||
INIT_ID(msg), \
|
||||
INIT_ID(mycmp), \
|
||||
|
|
@ -1166,6 +1172,7 @@ extern "C" {
|
|||
INIT_ID(salt), \
|
||||
INIT_ID(sched_priority), \
|
||||
INIT_ID(scheduler), \
|
||||
INIT_ID(second), \
|
||||
INIT_ID(seek), \
|
||||
INIT_ID(seekable), \
|
||||
INIT_ID(selectors), \
|
||||
|
|
@ -1242,6 +1249,7 @@ extern "C" {
|
|||
INIT_ID(type), \
|
||||
INIT_ID(type_params), \
|
||||
INIT_ID(tz), \
|
||||
INIT_ID(tzinfo), \
|
||||
INIT_ID(tzname), \
|
||||
INIT_ID(uid), \
|
||||
INIT_ID(unlink), \
|
||||
|
|
|
|||
24
Include/internal/pycore_unicodeobject_generated.h
generated
24
Include/internal/pycore_unicodeobject_generated.h
generated
|
|
@ -936,6 +936,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
|
|||
string = &_Py_ID(database);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(day);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(decode);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
|
|
@ -1143,6 +1146,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
|
|||
string = &_Py_ID(flush);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(fold);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(follow_symlinks);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
|
|
@ -1233,6 +1239,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
|
|||
string = &_Py_ID(hook);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(hour);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(id);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
|
|
@ -1485,6 +1494,12 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
|
|||
string = &_Py_ID(method);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(microsecond);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(minute);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(mod);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
|
|
@ -1500,6 +1515,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
|
|||
string = &_Py_ID(modules);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(month);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(mro);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
|
|
@ -1812,6 +1830,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
|
|||
string = &_Py_ID(scheduler);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(second);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(seek);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
|
|
@ -2040,6 +2061,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) {
|
|||
string = &_Py_ID(tz);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(tzinfo);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
string = &_Py_ID(tzname);
|
||||
assert(_PyUnicode_CheckConsistency(string, 1));
|
||||
_PyUnicode_InternInPlace(interp, &string);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue