@@ -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
@@ -2554,6 +2569,13 @@ def inferred_type(self) -> str_t:
2554
2569
"""
2555
2570
Return a string of the type inferred from the values.
2556
2571
"""
2572
+ if isinstance (self .dtype , np .dtype ) and self .dtype .kind in "iufc" : # fastpath
2573
+ return {
2574
+ "i" : "integer" ,
2575
+ "u" : "integer" ,
2576
+ "f" : "floating" ,
2577
+ "c" : "complex" ,
2578
+ }[self .dtype .kind ]
2557
2579
return lib .infer_dtype (self ._values , skipna = False )
2558
2580
2559
2581
@cache_readonly
0 commit comments