Skip to content

gh-153612: Add copyreg.copy() and copyreg.deepcopy()#153613

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:copyreg-copy-deepcopy
Open

gh-153612: Add copyreg.copy() and copyreg.deepcopy()#153613
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:copyreg-copy-deepcopy

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 12, 2026

Copy link
Copy Markdown
Member

Add registration of shallow and deep copy functions for instances of types that cannot be modified, following the copyreg.pickle() precedent. copy.copy() and copy.deepcopy() use the registered functions in preference to the __copy__/__deepcopy__ special methods and the pickle interfaces. Registration is by exact type and does not affect pickling.

The registries are the public tables copyreg.copy_dispatch_table and copyreg.deepcopy_dispatch_table, which also hold the handlers for the built-in container types. The private _deepcopy_dispatch is removed, following the removal of _copy_dispatch in gh-128118.

Closes gh-153612.

🤖 Generated with Claude Code

Register shallow and deep copy functions for instances of types that
cannot be modified.  copy.copy() and copy.deepcopy() use them in
preference to the __copy__ and __deepcopy__ special methods and the
pickle interfaces, without affecting pickling.

The public dispatch tables also hold the handlers for the built-in
container types; the private copy._deepcopy_dispatch is removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 12, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33549915 | 📁 Comparing a17b68b against main (0023d5b)

  🔍 Preview build  

7 files changed · ± 7 modified

± Modified

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add copyreg.copy() and copyreg.deepcopy()

1 participant