mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
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.
This commit is contained in:
parent
9f0c0a46f0
commit
6f3c138dfa
19 changed files with 311 additions and 68 deletions
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue