@@ -386,11 +386,26 @@ def _outer_indexer(
386
386
_attributes : list [str ] = ["name" ]
387
387
_can_hold_strings : bool = True
388
388
389
+ _engine_types : dict [np .dtype | ExtensionDtype , type [libindex .IndexEngine ]] = {
390
+ np .dtype (np .int8 ): libindex .Int8Engine ,
391
+ np .dtype (np .int16 ): libindex .Int16Engine ,
392
+ np .dtype (np .int32 ): libindex .Int32Engine ,
393
+ np .dtype (np .int64 ): libindex .Int64Engine ,
394
+ np .dtype (np .uint8 ): libindex .UInt8Engine ,
395
+ np .dtype (np .uint16 ): libindex .UInt16Engine ,
396
+ np .dtype (np .uint32 ): libindex .UInt32Engine ,
397
+ np .dtype (np .uint64 ): libindex .UInt64Engine ,
398
+ np .dtype (np .float32 ): libindex .Float32Engine ,
399
+ np .dtype (np .float64 ): libindex .Float64Engine ,
400
+ np .dtype (np .complex64 ): libindex .Complex64Engine ,
401
+ np .dtype (np .complex128 ): libindex .Complex128Engine ,
402
+ }
403
+
389
404
@property
390
405
def _engine_type (
391
406
self ,
392
407
) -> type [libindex .IndexEngine ] | type [libindex .ExtensionEngine ]:
393
- return libindex .ObjectEngine
408
+ return self . _engine_types . get ( self . dtype , libindex .ObjectEngine )
394
409
395
410
# whether we support partial string indexing. Overridden
396
411
# in DatetimeIndex and PeriodIndex
@@ -2540,12 +2555,34 @@ def holds_integer(self) -> bool:
2540
2555
)
2541
2556
return self ._holds_integer ()
2542
2557
2558
+ def _inferred_type (self ) -> str_t :
2559
+ """
2560
+ Return a string of the type inferred from the values.
2561
+ """
2562
+ try : # fastpath numeric indexes
2563
+ return {
2564
+ "i" : "integer" ,
2565
+ "u" : "integer" ,
2566
+ "f" : "floating" ,
2567
+ "c" : "complex" ,
2568
+ }[self .dtype .kind ]
2569
+ except KeyError :
2570
+ return lib .infer_dtype (self ._values , skipna = False )
2571
+
2543
2572
@cache_readonly
2544
2573
def inferred_type (self ) -> str_t :
2545
2574
"""
2546
2575
Return a string of the type inferred from the values.
2547
2576
"""
2548
- return lib .infer_dtype (self ._values , skipna = False )
2577
+ try :
2578
+ return {
2579
+ "i" : "integer" ,
2580
+ "u" : "integer" ,
2581
+ "f" : "floating" ,
2582
+ "c" : "complex" ,
2583
+ }[self .dtype .kind ]
2584
+ except KeyError :
2585
+ return lib .infer_dtype (self ._values , skipna = False )
2549
2586
2550
2587
@cache_readonly
2551
2588
@final
0 commit comments