| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I think we could consider adding these to the datamodel and moving out of copy, I don't know what you'd think? A |
Sorry, something went wrong.
|
The markup changes for copy/deepcopy should be backported; replace should be left out. A |
Sorry, something went wrong.
Keeping these methods in the copy docs isn't without precedent: __fspath__ is documented in the os docs; __subclasshook__ is documented in the abc docs. I think there's an argument for keeping them close to the functions they're relevant to. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM.
Sorry, something went wrong.
| The memo dictionary should be treated as an opaque object. | ||
| special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`. | ||
|
|
||
| .. method:: object.__copy__(self) |
There was a problem hiding this comment.
But please keep :noindex:. There are already entries for __replace__ etc, and duplicates that refer to the same target are confusing.
Sorry, something went wrong.
There was a problem hiding this comment.
Hm, when adding noindex it starts to fail nitpick mode:
/Users/sobolev/Desktop/cpython/Doc/library/copy.rst:90: WARNING: py:meth reference target not found: object.__copy__ /Users/sobolev/Desktop/cpython/Doc/library/copy.rst:90: WARNING: py:meth reference target not found: object.__deepcopy__ /Users/sobolev/Desktop/cpython/Doc/library/copy.rst:112: WARNING: py:meth reference target not found: object.__replace__
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
You could consider :noindexentry:?
A
Sorry, something went wrong.
There was a problem hiding this comment.
It generated just one link in index.html: copy.html#index-2
No warnings 👍
Thanks, TIL about noindexentry :)
Sorry, something went wrong.
| Function :func:`replace` is more limited than :func:`copy` and :func:`deepcopy`, | ||
| and only supports named tuples created by :func:`~collections.namedtuple`, | ||
| :mod:`dataclasses`, and other classes which define method :meth:`!__replace__`. | ||
| :mod:`dataclasses`, and other classes which define method :meth:`~object.__replace__`. |
There was a problem hiding this comment.
This answers a question I had: with noindexentry, can we still link to the method.
I just hope it’s not indexed as copy.object instead of builtins.object!
Sorry, something went wrong.
There was a problem hiding this comment.
Of course, it is copy.object. https://cpython-previews--109968.org.readthedocs.build/en/109968/library/copy.html#copy.object.__replace__
You need to add .. currentmodule:: . to make it builtin.
Sorry, something went wrong.
|
Sorry, @sobolevn and @hugovk, I could not cleanly backport this to 3.12 due to a conflict. |
Sorry, something went wrong.
|
Sorry, @sobolevn and @hugovk, I could not cleanly backport this to 3.11 due to a conflict. |
Sorry, something went wrong.
|
@sobolevn Please could you do the backports? Thank you! |
Sorry, something went wrong.
|
I think this needs a follow-up PR for Serhiy's note: #109968 (comment) A |
Sorry, something went wrong.
|
Will do both :) |
Sorry, something went wrong.
@sobolevn Still needed? If not, let's remove the backport label. |
Sorry, something went wrong.
…` in `copy.rst` (pythonGH-109968) (cherry picked from commit 0baf726) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
GH-130909 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is how it looks now:

I've also added __copy__ and __deepcopy__ definitions, so they can be referenced.
Refs #101100
📚 Documentation preview 📚: https://cpython-previews--109968.org.readthedocs.build/