Skip to content

Commit 0200928

Browse files
shoyerbriancurtin
authored andcommitted
Include memo in the documented signature of copy.deepcopy()
* Include memo in the documented signature of copy.deepcopy() The memo argument is mentioned lower on the doc page under writing a `__deepcopy__` method, but is not included in the documented function signature. This makes it easy to miss, and can lead to incorrect/buggy implementations of `__deepcopy__` -- which is exatly what just happpend to me!
1 parent 3b05ad7 commit 0200928

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/library/copy.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Interface summary:
2222
Return a shallow copy of *x*.
2323

2424

25-
.. function:: deepcopy(x)
25+
.. function:: deepcopy(x[, memo])
2626

2727
Return a deep copy of *x*.
2828

@@ -52,7 +52,7 @@ copy operations:
5252

5353
The :func:`deepcopy` function avoids these problems by:
5454

55-
* keeping a "memo" dictionary of objects already copied during the current
55+
* keeping a ``memo`` dictionary of objects already copied during the current
5656
copying pass; and
5757

5858
* letting user-defined classes override the copying operation or the set of
@@ -82,7 +82,7 @@ In order for a class to define its own copy implementation, it can define
8282
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
8383
to implement the shallow copy operation; no additional arguments are passed.
8484
The latter is called to implement the deep copy operation; it is passed one
85-
argument, the memo dictionary. If the :meth:`__deepcopy__` implementation needs
85+
argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
8686
to make a deep copy of a component, it should call the :func:`deepcopy` function
8787
with the component as first argument and the memo dictionary as second argument.
8888

0 commit comments

Comments
 (0)