Skip to content

Commit d67dab8

Browse files
improve performance of PandasDtype construction (lazy dtype.name)
1 parent 8f5d886 commit d67dab8

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

pandas/core/arrays/numpy_.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class PandasDtype(ExtensionDtype):
4343
def __init__(self, dtype):
4444
dtype = np.dtype(dtype)
4545
self._dtype = dtype
46-
self._name = dtype.name
4746
self._type = dtype.type
4847

4948
def __repr__(self) -> str:
@@ -56,7 +55,7 @@ def numpy_dtype(self):
5655

5756
@property
5857
def name(self):
59-
return self._name
58+
return self._dtype.name
6059

6160
@property
6261
def type(self):

pandas/core/internals/blocks.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
Categorical,
7171
DatetimeArray,
7272
ExtensionArray,
73+
PandasArray,
7374
PandasDtype,
7475
TimedeltaArray,
7576
)
@@ -219,8 +220,6 @@ def array_values(self) -> ExtensionArray:
219220
"""
220221
The array that Series.array returns. Always an ExtensionArray.
221222
"""
222-
from pandas.core.arrays.numpy_ import PandasArray
223-
224223
return PandasArray(self.values)
225224

226225
def get_values(self, dtype=None):

0 commit comments

Comments
 (0)