https://github.com/python/cpython/commit/1de909b32411fc1c4d4c42b4f8221b86096c6353
commit: 1de909b32411fc1c4d4c42b4f8221b86096c6353
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-05-31T15:08:55+03:00
summary:

gh-150636: Clarify difference between copy.copy() and the copy() methods 
(GH-150637)

Co-authored-by: Pieter Eendebak <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>

files:
M Doc/library/copy.rst

diff --git a/Doc/library/copy.rst b/Doc/library/copy.rst
index 121c44a16ad43b..39fc7800d03a91 100644
--- a/Doc/library/copy.rst
+++ b/Doc/library/copy.rst
@@ -72,9 +72,13 @@ file, socket, window, or any similar types.  It does "copy" 
functions and
 classes (shallow and deeply), by returning the original object unchanged; this
 is compatible with the way these are treated by the :mod:`pickle` module.
 
-Shallow copies of dictionaries can be made using :meth:`dict.copy`, and
-of lists by assigning a slice of the entire list, for example,
-``copied_list = original_list[:]``.
+Shallow copies of many collections can be made using the corresponding
+:meth:`!copy` method (such as :meth:`list.copy`, :meth:`dict.copy` or
+:meth:`set.copy`), and of sequences (such as lists or bytearrays) by making
+a slice of the entire sequence (``sequence[:]``).
+However, these methods and slicing can create an instance of the base type
+when copying an instance of a subclass, whereas :func:`copy.copy` normally
+returns an instance of the same type.
 
 .. index:: pair: module; pickle
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to