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 @@ -529,6 +529,7 @@ Performance improvements
529
529
- Performance improvement in :class: `Styler ` where render times are more than 50% reduced (:issue: `39972 ` :issue: `39952 `)
530
530
- Performance improvement in :meth: `core.window.ewm.ExponentialMovingWindow.mean ` with ``times `` (:issue: `39784 `)
531
531
- Performance improvement in :meth: `.GroupBy.apply ` when requiring the python fallback implementation (:issue: `40176 `)
532
+ - Performance improvement for concatenation of data with type :class: `CategoricalDtype ` (:issue: `40193 `)
532
533
533
534
.. ---------------------------------------------------------------------------
534
535
Original file line number Diff line number Diff line change 21
21
import pytz
22
22
23
23
from pandas ._libs .interval import Interval
24
+ from pandas ._libs .properties import cache_readonly
24
25
from pandas ._libs .tslibs import (
25
26
BaseOffset ,
26
27
NaT ,
@@ -360,7 +361,7 @@ def __hash__(self) -> int:
360
361
else :
361
362
return - 2
362
363
# We *do* want to include the real self.ordered here
363
- return int (self ._hash_categories ( self . categories , self . ordered ) )
364
+ return int (self ._hash_categories )
364
365
365
366
def __eq__ (self , other : Any ) -> bool :
366
367
"""
@@ -434,14 +435,17 @@ def __repr__(self) -> str_type:
434
435
data = data .rstrip (", " )
435
436
return f"CategoricalDtype(categories={ data } , ordered={ self .ordered } )"
436
437
437
- @staticmethod
438
- def _hash_categories (categories , ordered : Ordered = True ) -> int :
438
+ @cache_readonly
439
+ def _hash_categories (self ) -> int :
439
440
from pandas .core .util .hashing import (
440
441
combine_hash_arrays ,
441
442
hash_array ,
442
443
hash_tuples ,
443
444
)
444
445
446
+ categories = self .categories
447
+ ordered = self .ordered
448
+
445
449
if len (categories ) and isinstance (categories [0 ], tuple ):
446
450
# assumes if any individual category is a tuple, then all our. ATM
447
451
# 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