File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -567,6 +567,7 @@ Performance improvements
567
567
- Performance improvement in :class: `Styler ` where render times are more than 50% reduced (:issue: `39972 ` :issue: `39952 `)
568
568
- Performance improvement in :meth: `core.window.ewm.ExponentialMovingWindow.mean ` with ``times `` (:issue: `39784 `)
569
569
- Performance improvement in :meth: `.GroupBy.apply ` when requiring the python fallback implementation (:issue: `40176 `)
570
+ - Performance improvement for concatenation of data with type :class: `CategoricalDtype ` (:issue: `40193 `)
570
571
571
572
.. ---------------------------------------------------------------------------
572
573
Original file line number Diff line number Diff line change 15
15
import pytz
16
16
17
17
from pandas ._libs .interval import Interval
18
+ from pandas ._libs .properties import cache_readonly
18
19
from pandas ._libs .tslibs import (
19
20
BaseOffset ,
20
21
NaT ,
@@ -355,7 +356,7 @@ def __hash__(self) -> int:
355
356
else :
356
357
return - 2
357
358
# We *do* want to include the real self.ordered here
358
- return int (self ._hash_categories ( self . categories , self . ordered ) )
359
+ return int (self ._hash_categories )
359
360
360
361
def __eq__ (self , other : Any ) -> bool :
361
362
"""
@@ -429,14 +430,17 @@ def __repr__(self) -> str_type:
429
430
data = data .rstrip (", " )
430
431
return f"CategoricalDtype(categories={ data } , ordered={ self .ordered } )"
431
432
432
- @staticmethod
433
- def _hash_categories (categories , ordered : Ordered = True ) -> int :
433
+ @cache_readonly
434
+ def _hash_categories (self ) -> int :
434
435
from pandas .core .util .hashing import (
435
436
combine_hash_arrays ,
436
437
hash_array ,
437
438
hash_tuples ,
438
439
)
439
440
441
+ categories = self .categories
442
+ ordered = self .ordered
443
+
440
444
if len (categories ) and isinstance (categories [0 ], tuple ):
441
445
# assumes if any individual category is a tuple, then all our. ATM
442
446
# I don't really want to support just some of the categories being
You can’t perform that action at this time.
0 commit comments