From bdff1aab54cb15b7819d3e1e99b55ec5683c0d55 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Thu, 16 Nov 2023 14:49:01 +0100 Subject: [PATCH] feat: enable copy-on-write for pandas dataframes --- src/safeds/data/tabular/containers/_column.py | 3 +++ src/safeds/data/tabular/containers/_row.py | 3 +++ src/safeds/data/tabular/containers/_table.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/safeds/data/tabular/containers/_column.py b/src/safeds/data/tabular/containers/_column.py index 015fe60d2..54c7e2531 100644 --- a/src/safeds/data/tabular/containers/_column.py +++ b/src/safeds/data/tabular/containers/_column.py @@ -27,6 +27,9 @@ T = TypeVar("T") R = TypeVar("R") +# Enable copy-on-write for pandas dataframes +pd.set_option("mode.copy_on_write", True) + class Column(Sequence[T]): """ diff --git a/src/safeds/data/tabular/containers/_row.py b/src/safeds/data/tabular/containers/_row.py index 6994b3248..ac87673ec 100644 --- a/src/safeds/data/tabular/containers/_row.py +++ b/src/safeds/data/tabular/containers/_row.py @@ -13,6 +13,9 @@ if TYPE_CHECKING: from collections.abc import Iterator +# Enable copy-on-write for pandas dataframes +pd.set_option("mode.copy_on_write", True) + class Row(Mapping[str, Any]): """ diff --git a/src/safeds/data/tabular/containers/_table.py b/src/safeds/data/tabular/containers/_table.py index 63c9a7cff..e8851422b 100644 --- a/src/safeds/data/tabular/containers/_table.py +++ b/src/safeds/data/tabular/containers/_table.py @@ -39,6 +39,9 @@ from ._tagged_table import TaggedTable +# Enable copy-on-write for pandas dataframes +pd.set_option("mode.copy_on_write", True) + # noinspection PyProtectedMember class Table: