@@ -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
@@ -2521,12 +2536,34 @@ def holds_integer(self) -> bool:
2521
2536
)
2522
2537
return self ._holds_integer ()
2523
2538
2539
+ def _inferred_type (self ) -> str_t :
2540
+ """
2541
+ Return a string of the type inferred from the values.
2542
+ """
2543
+ try : # fastpath numeric indexes
2544
+ return {
2545
+ "i" : "integer" ,
2546
+ "u" : "integer" ,
2547
+ "f" : "floating" ,
2548
+ "c" : "complex" ,
2549
+ }[self .dtype .kind ]
2550
+ except KeyError :
2551
+ return lib .infer_dtype (self ._values , skipna = False )
2552
+
2524
2553
@cache_readonly
2525
2554
def inferred_type (self ) -> str_t :
2526
2555
"""
2527
2556
Return a string of the type inferred from the values.
2528
2557
"""
2529
- return lib .infer_dtype (self ._values , skipna = False )
2558
+ try :
2559
+ return {
2560
+ "i" : "integer" ,
2561
+ "u" : "integer" ,
2562
+ "f" : "floating" ,
2563
+ "c" : "complex" ,
2564
+ }[self .dtype .kind ]
2565
+ except KeyError :
2566
+ return lib .infer_dtype (self ._values , skipna = False )
2530
2567
2531
2568
@cache_readonly
2532
2569
@final
0 commit comments