Skip to content

gh-134559: Expand and reorganise documentation for the copy module#134695

Open
ferdnyc wants to merge 3 commits intopython:mainfrom
ferdnyc:copy-mod-docs
Open

gh-134559: Expand and reorganise documentation for the copy module#134695
ferdnyc wants to merge 3 commits intopython:mainfrom
ferdnyc:copy-mod-docs

Conversation

@ferdnyc
Copy link
Copy Markdown
Contributor

@ferdnyc ferdnyc commented May 26, 2025

The documentation for the copy module was showing its age. Reorganize with additional headings and more uniform structure.

Fixes: #134559

ferdnyc added 2 commits May 26, 2025 04:20
The documentation for the copy module was showing its age.
Reorganize with additional headings and more uniform structure.

Fixes: python#134559
Comment thread Doc/library/copy.rst
Comment on lines +36 to +37
The difference between shallow and deep copying is only relevant for compound
objects (objects that contain other objects, like lists or class instances):
Copy link
Copy Markdown
Member

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

Suggested change
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:

Comment thread Doc/library/copy.rst
Comment on lines +117 to +118
``replace``
-----------
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``replace``
-----------
:func:`!replace()`
------------------

Comment thread Doc/library/copy.rst
Comment on lines +125 to +129
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__`).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).

@AA-Turner AA-Turner changed the title gh-134559: Expand, reorganize copy module docs gh-134559: Expand and reorganise documentation for the copy module May 26, 2025
Comment thread Doc/library/copy.rst
Comment on lines +19 to +20
``copy`` and ``deepcopy``
-------------------------
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``copy`` and ``deepcopy``
-------------------------
:func:`!copy()` and :func:`!deepcopy()`
---------------------------------------

Comment thread Doc/library/copy.rst
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__`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(i.e. define a method :meth:`~object.__replace__`).
(that is, those defining a :meth:`~object.__replace__` method).

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Improve documentation for the copy module

3 participants