-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
DOC: clarify behavior of shallow copy with Copy-on-Write in NDFrame docstring #63291
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6542,23 +6542,18 @@ def copy(self, deep: bool = True) -> Self: | |
|
|
||
| When ``deep=False``, a new object will be created without copying | ||
| the calling object's data or index (only references to the data | ||
| and index are copied). Any changes to the data of the original | ||
| will be reflected in the shallow copy (and vice versa). | ||
| and index are copied). With Copy-on-Write enabled by default, | ||
| changes to the data of the original will *not* be reflected in the | ||
| shallow copy (and vice versa). The shallow copy uses a lazy (deferred) | ||
|
||
| copy mechanism that copies the data only when any changes to the | ||
| original or shallow copy are made, ensuring memory efficiency while | ||
| maintaining data integrity. | ||
|
|
||
| .. note:: | ||
| The ``deep=False`` behaviour as described above will change | ||
| in pandas 3.0. `Copy-on-Write | ||
| <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__ | ||
| will be enabled by default, which means that the "shallow" copy | ||
| is that is returned with ``deep=False`` will still avoid making | ||
| an eager copy, but changes to the data of the original will *no* | ||
| longer be reflected in the shallow copy (or vice versa). Instead, | ||
| it makes use of a lazy (deferred) copy mechanism that will copy | ||
| the data only when any changes to the original or shallow copy is | ||
| made. | ||
|
|
||
| You can already get the future behavior and improvements through | ||
| enabling copy on write ``pd.options.mode.copy_on_write = True`` | ||
| In pandas versions prior to 3.0, the default behavior without | ||
| Copy-on-Write was different: changes to the data of the original | ||
| *were* reflected in the shallow copy (and vice versa). See the | ||
| :ref:`Copy-on-Write user guide <copy_on_write>` for more information. | ||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
||
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.
Since CoW can't be disabled, I think we should remove the "enabled by default" bit.
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've removed the phase
enabled by default