Skip to content

Commit 862fb31

Browse files
committed
DEPR: Copy-on-Write option
1 parent fb517ba commit 862fb31

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

pandas/core/config_init.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,11 @@ def is_terminal() -> bool:
408408
cf.register_option("sim_interactive", False, tc_sim_interactive_doc)
409409

410410

411-
# TODO better name?
412411
copy_on_write_doc = """
413412
: bool
414-
Use new copy-view behaviour using Copy-on-Write. Defaults to False,
415-
unless overridden by the 'PANDAS_COPY_ON_WRITE' environment variable
416-
(if set to "1" for True, needs to be set before pandas is imported).
413+
Use new copy-view behaviour using Copy-on-Write. No longer used,
414+
pandas now always uses Copy-on-Write behavior. This option will
415+
be removed in pandas 4.0.
417416
"""
418417

419418

@@ -902,3 +901,11 @@ def register_converter_cb(key: str) -> None:
902901

903902
# GH#59502
904903
cf.deprecate_option("future.no_silent_downcasting", Pandas4Warning)
904+
cf.deprecate_option(
905+
"mode.copy_on_write",
906+
Pandas4Warning,
907+
msg=(
908+
"Copy-on-Write can no longer be disabled, setting to False has no impact. "
909+
"This option will be removed in pandas 4.0."
910+
),
911+
)

pandas/tests/copy_view/test_copy_deprecation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,10 @@ def test_copy_deprecation_merge_concat():
8989
Pandas4Warning, match="copy", check_stacklevel=False
9090
):
9191
concat([df, df], copy=False)
92+
93+
94+
@pytest.mark.parametrize("value", [False, True, "warn"])
95+
def test_copy_on_write_deprecation_option(value):
96+
msg = "Copy-on-Write can no longer be disabled"
97+
with tm.assert_produces_warning(Pandas4Warning, match=msg):
98+
pd.set_option("mode.copy_on_write", value)

0 commit comments

Comments
 (0)