Skip to content

Commit 5c27aa2

Browse files
committed
PERF: Remove unnecessary(?) asof join functions
Several functions in the join cython are module are basically just calling others, and can probably be removed. This wouldn't be a big deal inside python, but in this case it cuts down considerably on the number of generated cython code. The tests pass for me locally when I do this and there seems to be significant space savings. Will provide more detail after I see CI passing (want to make sure I'm not missing something first)
1 parent dbe39f1 commit 5c27aa2

File tree

2 files changed

+2
-59
lines changed

2 files changed

+2
-59
lines changed

pandas/_libs/join.pyx

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -894,55 +894,3 @@ cdef _choose_smaller_timestamp(
894894
left_indexer[i] = bli[i]
895895

896896
return left_indexer, right_indexer
897-
898-
899-
# ----------------------------------------------------------------------
900-
# asof_join
901-
# ----------------------------------------------------------------------
902-
903-
def asof_join_backward(numeric_t[:] left_values,
904-
numeric_t[:] right_values,
905-
bint allow_exact_matches=True,
906-
tolerance=None):
907-
908-
return asof_join_backward_on_X_by_Y(
909-
left_values,
910-
right_values,
911-
None,
912-
None,
913-
allow_exact_matches=allow_exact_matches,
914-
tolerance=tolerance,
915-
use_hashtable=False,
916-
)
917-
918-
919-
def asof_join_forward(numeric_t[:] left_values,
920-
numeric_t[:] right_values,
921-
bint allow_exact_matches=True,
922-
tolerance=None):
923-
return asof_join_forward_on_X_by_Y(
924-
left_values,
925-
right_values,
926-
None,
927-
None,
928-
allow_exact_matches=allow_exact_matches,
929-
tolerance=tolerance,
930-
use_hashtable=False,
931-
)
932-
933-
934-
def asof_join_nearest(numeric_t[:] left_values,
935-
numeric_t[:] right_values,
936-
bint allow_exact_matches=True,
937-
tolerance=None):
938-
939-
cdef:
940-
ndarray[intp_t] bli, bri, fli, fri
941-
942-
# search both forward and backward
943-
bli, bri = asof_join_backward(left_values, right_values,
944-
allow_exact_matches, tolerance)
945-
fli, fri = asof_join_forward(left_values, right_values,
946-
allow_exact_matches, tolerance)
947-
948-
return _choose_smaller_timestamp(left_values, right_values, bli, bri, fli, fri)

pandas/core/reshape/merge.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,11 +1691,6 @@ def get_result(self) -> DataFrame:
16911691
return result
16921692

16931693

1694-
def _asof_function(direction: str):
1695-
name = f"asof_join_{direction}"
1696-
return getattr(libjoin, name, None)
1697-
1698-
16991694
def _asof_by_function(direction: str):
17001695
name = f"asof_join_{direction}_on_X_by_Y"
17011696
return getattr(libjoin, name, None)
@@ -2017,8 +2012,8 @@ def injection(obj):
20172012
)
20182013
else:
20192014
# choose appropriate function by type
2020-
func = _asof_function(self.direction)
2021-
return func(left_values, right_values, self.allow_exact_matches, tolerance)
2015+
func = _asof_by_function(self.direction)
2016+
return func(left_values, right_values, None, None, self.allow_exact_matches, tolerance)
20222017

20232018

20242019
def _get_multiindex_indexer(

0 commit comments

Comments
 (0)