BUG: fix IntegerArray astype with copy=True/False by jorisvandenbossche · Pull Request #34931 · pandas-dev/pandas (original) (raw)
One additional API question that pops up: in numpy, astype(.., copy=False)
seems to return itself if it doesn't need to copy (I am actually also relying on this in the if data is self._data
check).
But in the EA implementation, we always return a new array object, potentially with the same backing data. But we could in principle also do something like if dtype == self.dtype and not copy: return self
(and that should already catch the one case where a copy can be avoided I think, and we could simply always copy in the other cases)