diff --git a/pandas/_config/__init__.py b/pandas/_config/__init__.py index 73ed99c3a4640..4c9a38a99aa36 100644 --- a/pandas/_config/__init__.py +++ b/pandas/_config/__init__.py @@ -31,6 +31,28 @@ def using_copy_on_write() -> bool: + """ + Determine if copy-on-write mode is enabled. + + Copy-on-write is a memory-saving technique that avoids copying data + until it is actually modified, which can be particularly useful when + working with large datasets. + + Returns + ------- + bool + 'True' if copy-on-write mode is enabled and the data manager + is set to "block", otherwise 'False'. + + Example + ------- + >>> pd.set_option("mode.copy_on_write", True) + >>> using_copy_on_write() + True + >>> pd.set_option("mode.copy_on_write", False) + >>> using_copy_on_write() + False + """ _mode_options = _global_config["mode"] return _mode_options["copy_on_write"] and _mode_options["data_manager"] == "block"