Skip to content

Commit 7f53afc

Browse files
authored
CoW: Add property for references to series class (#51732)
1 parent d9ba285 commit 7f53afc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pandas/core/internals/construction.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,7 @@ def _homogenize(
567567
# Forces alignment. No need to copy data since we
568568
# are putting it into an ndarray later
569569
val = val.reindex(index, copy=False)
570-
if isinstance(val._mgr, SingleBlockManager):
571-
refs.append(val._mgr._block.refs)
572-
else:
573-
refs.append(None)
570+
refs.append(val._references)
574571
val = val._values
575572
else:
576573
if isinstance(val, dict):

pandas/core/series.py

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
properties,
3535
reshape,
3636
)
37+
from pandas._libs.internals import BlockValuesRefs
3738
from pandas._libs.lib import (
3839
is_range_indexer,
3940
no_default,
@@ -734,6 +735,12 @@ def _values(self):
734735
"""
735736
return self._mgr.internal_values()
736737

738+
@property
739+
def _references(self) -> BlockValuesRefs | None:
740+
if isinstance(self._mgr, SingleArrayManager):
741+
return None
742+
return self._mgr._block.refs
743+
737744
# error: Decorated property not supported
738745
@Appender(base.IndexOpsMixin.array.__doc__) # type: ignore[misc]
739746
@property

0 commit comments

Comments
 (0)