@@ -59,6 +59,7 @@ class Index(np.ndarray):
59
59
# Cython methods
60
60
_groupby = _algos .groupby_object
61
61
_arrmap = _algos .arrmap_object
62
+ _left_indexer_unique = _algos .left_join_indexer_unique_object
62
63
_left_indexer = _algos .left_join_indexer_object
63
64
_inner_indexer = _algos .inner_join_indexer_object
64
65
_outer_indexer = _algos .outer_join_indexer_object
@@ -726,6 +727,7 @@ def _possibly_promote(self, other):
726
727
def _get_indexer_standard (self , other ):
727
728
if (self .dtype != np .object_ and
728
729
self .is_monotonic and other .is_monotonic ):
730
+ # TODO: unique vs non unique
729
731
return self ._left_indexer (other , self )
730
732
else :
731
733
return self ._engine .get_indexer (other )
@@ -938,21 +940,35 @@ def _join_monotonic(self, other, how='left', return_indexers=False):
938
940
else :
939
941
return ret_index
940
942
941
- if how == 'left' :
942
- join_index = self
943
- lidx = None
944
- ridx = self ._left_indexer (self , other )
945
- elif how == 'right' :
946
- join_index = other
947
- lidx = self ._left_indexer (other , self )
948
- ridx = None
949
- elif how == 'inner' :
950
- join_index , lidx , ridx = self ._inner_indexer (self .values ,
951
- other .values )
952
- join_index = self ._wrap_joined_index (join_index , other )
953
- elif how == 'outer' :
954
- join_index , lidx , ridx = self ._outer_indexer (self .values ,
955
- other .values )
943
+ if self .is_unique and other .is_unique :
944
+ # We can perform much better than the general case
945
+ if how == 'left' :
946
+ join_index = self
947
+ lidx = None
948
+ ridx = self ._left_indexer_unique (self , other )
949
+ elif how == 'right' :
950
+ join_index = other
951
+ lidx = self ._left_indexer_unique (other , self )
952
+ ridx = None
953
+ elif how == 'inner' :
954
+ join_index , lidx , ridx = self ._inner_indexer (self .values ,
955
+ other .values )
956
+ join_index = self ._wrap_joined_index (join_index , other )
957
+ elif how == 'outer' :
958
+ join_index , lidx , ridx = self ._outer_indexer (self .values ,
959
+ other .values )
960
+ join_index = self ._wrap_joined_index (join_index , other )
961
+ else :
962
+ if how == 'left' :
963
+ join_index , lidx , ridx = self ._left_indexer (self , other )
964
+ elif how == 'right' :
965
+ join_index , ridx , lidx = self ._left_indexer (other , self )
966
+ elif how == 'inner' :
967
+ join_index , lidx , ridx = self ._inner_indexer (self .values ,
968
+ other .values )
969
+ elif how == 'outer' :
970
+ join_index , lidx , ridx = self ._outer_indexer (self .values ,
971
+ other .values )
956
972
join_index = self ._wrap_joined_index (join_index , other )
957
973
958
974
if return_indexers :
@@ -1074,6 +1090,7 @@ class Int64Index(Index):
1074
1090
1075
1091
_groupby = _algos .groupby_int64
1076
1092
_arrmap = _algos .arrmap_int64
1093
+ _left_indexer_unique = _algos .left_join_indexer_unique_int64
1077
1094
_left_indexer = _algos .left_join_indexer_int64
1078
1095
_inner_indexer = _algos .inner_join_indexer_int64
1079
1096
_outer_indexer = _algos .outer_join_indexer_int64
0 commit comments