Commit 0200928e authored by Stephan Hoyer's avatar Stephan Hoyer Committed by Brian Curtin

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!
parent 3b05ad7b
...@@ -22,7 +22,7 @@ Interface summary: ...@@ -22,7 +22,7 @@ Interface summary:
Return a shallow copy of *x*. Return a shallow copy of *x*.
.. function:: deepcopy(x) .. function:: deepcopy(x[, memo])
Return a deep copy of *x*. Return a deep copy of *x*.
...@@ -52,7 +52,7 @@ copy operations: ...@@ -52,7 +52,7 @@ copy operations:
The :func:`deepcopy` function avoids these problems by: The :func:`deepcopy` function avoids these problems by:
* keeping a "memo" dictionary of objects already copied during the current * keeping a ``memo`` dictionary of objects already copied during the current
copying pass; and copying pass; and
* letting user-defined classes override the copying operation or the set of * 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 ...@@ -82,7 +82,7 @@ In order for a class to define its own copy implementation, it can define
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
to implement the shallow copy operation; no additional arguments are passed. to implement the shallow copy operation; no additional arguments are passed.
The latter is called to implement the deep copy operation; it is passed one The latter is called to implement the deep copy operation; it is passed one
argument, the memo dictionary. If the :meth:`__deepcopy__` implementation needs argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the memo dictionary as second argument. with the component as first argument and the memo dictionary as second argument.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment