-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-134559: Expand and reorganise documentation for the copy
module
#134695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The documentation for the copy module was showing its age. Reorganize with additional headings and more uniform structure. Fixes: python#134559
The difference between shallow and deep copying is only relevant for compound | ||
objects (objects that contain other objects, like lists or class instances): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'container' is more commonly used and the name of a collections ABC
The difference between shallow and deep copying is only relevant for compound | |
objects (objects that contain other objects, like lists or class instances): | |
The difference between shallow and deep copying is only relevant for container | |
objects; those that contain other objects, like lists or class instances: |
``replace`` | ||
----------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``replace`` | |
----------- | |
:func:`!replace()` | |
------------------ |
Function :func:`!copy.replace` is more limited | ||
than :func:`~copy.copy` and :func:`~copy.deepcopy`, | ||
and only supports named tuples created by :func:`~collections.namedtuple`, | ||
:mod:`dataclasses`, and other classes which implement the replace protocol | ||
(i.e. define a method :meth:`~object.__replace__`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function :func:`!copy.replace` is more limited | |
than :func:`~copy.copy` and :func:`~copy.deepcopy`, | |
and only supports named tuples created by :func:`~collections.namedtuple`, | |
:mod:`dataclasses`, and other classes which implement the replace protocol | |
(i.e. define a method :meth:`~object.__replace__`). | |
The :func:`!replace` function is more limited than | |
:func:`~copy.copy` and :func:`~copy.deepcopy`. | |
For example, it only supports named tuples created by :func:`~collections.namedtuple`, | |
:mod:`dataclasses`, and other classes which implement the replace protocol | |
(i.e. those defining a :meth:`~object.__replace__` method). |
copy
module
``copy`` and ``deepcopy`` | ||
------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``copy`` and ``deepcopy`` | |
------------------------- | |
:func:`!copy()` and :func:`!deepcopy()` | |
--------------------------------------- |
than :func:`~copy.copy` and :func:`~copy.deepcopy`, | ||
and only supports named tuples created by :func:`~collections.namedtuple`, | ||
:mod:`dataclasses`, and other classes which implement the replace protocol | ||
(i.e. define a method :meth:`~object.__replace__`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(i.e. define a method :meth:`~object.__replace__`). | |
(that is, those defining a :meth:`~object.__replace__` method). |
The documentation for the copy module was showing its age. Reorganize with additional headings and more uniform structure.
Fixes: #134559
copy
module #134559