aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-09-06 23:55:42 +0300
committerGitHub <noreply@github.com>2023-09-06 23:55:42 +0300
commit6f3c138dfa868b32d3288898923bbfa388f2fa5d (patch)
tree98098db4d0d2f256f2a17d515c1750a28424166c /Objects/codeobject.c
parent9f0c0a46f00d687e921990ee83894b2f4ce8a6e7 (diff)
downloadcpython-6f3c138dfa868b32d3288898923bbfa388f2fa5d.tar.gz
cpython-6f3c138dfa868b32d3288898923bbfa388f2fa5d.zip
gh-108751: Add copy.replace() function (GH-108752)
It creates a modified copy of an object by calling the object's __replace__() method. It is a generalization of dataclasses.replace(), named tuple's _replace() method and replace() methods in various classes, and supports all these stdlib classes.
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 70a0c2ebd66..58306075cad 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -2145,6 +2145,7 @@ static struct PyMethodDef code_methods[] = {
{"co_positions", (PyCFunction)code_positionsiterator, METH_NOARGS},
CODE_REPLACE_METHODDEF
CODE__VARNAME_FROM_OPARG_METHODDEF
+ {"__replace__", _PyCFunction_CAST(code_replace), METH_FASTCALL|METH_KEYWORDS},
{NULL, NULL} /* sentinel */
};