-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API / CoW: constructing Series from Series creates lazy copy (with default copy=False) #49524
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
API / CoW: constructing Series from Series creates lazy copy (with default copy=False) #49524
Conversation
…fault copy=False)
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.
lgtm, I would be ok with changing the behavior
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.
LGTM too. Could use a whatsnew note
doc/source/whatsnew/v2.0.0.rst
Outdated
@@ -77,6 +77,13 @@ be set to ``"pyarrow"`` to return pyarrow-backed, nullable :class:`ArrowDtype` ( | |||
df_pyarrow = pd.read_csv(data, use_nullable_dtypes=True, engine="pyarrow") | |||
df_pyarrow.dtypes | |||
|
|||
Copy on write improvements | |||
^^^^^^^^^^^^^^^^^^^^^^^^^^ |
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.
Added a new section like is being added in #50471. We can consolidate those different blurbs later on in a coherent whatsnew.
I updated this to put the actual code change behind a "if CoW" check (so this PR only changes something for the case of CoW enabled), and will do a separate PR to address #49523 (and for both Series and DataFrame). |
xref #48998 (bullet point about constructors)
In the CoW proposal, the idea for constructors would be that those follow the lazy copy with CoW approach as well, just like other methods and indexing operations that create a new Series/DataFrame from another Series/DataFrame.
That was not yet implemented in the initial implementation, and this PR is adding it for the
Series(series)
case.Currently, the way I implemented this is by making a shallow copy of the manager. This however also affects the default (non-CoW) behaviour -> see #49523.
Depending on whether we are OK with changing ("fixing"?) that behaviour in 2.0 or not, I can leave this as is, or otherwise put the copy behind a
if get_cnofig("mode.copy_on_write")
check.doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.