Skip to content

Commit 2bce3cc

Browse files
author
Christopher C. Aycock
committed
Revert dict back to PyObjectHashTable in response to code review
1 parent fafbb02 commit 2bce3cc

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

pandas/src/joins_func_helper.pxi.in

+7-12
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
1111

1212
{{py:
1313

14-
# by_dtype, table_type, init_table, s1, s2, s3, g1, g2
15-
by_dtypes = [('int64_t', 'Int64HashTable', 'Int64HashTable(right_size)',
16-
'.set_item(', ', ', ')',
17-
'.get_item(', ')'),
18-
('object', 'dict', '{}',
19-
'[', '] = ', '',
20-
'[', ']')]
14+
# table_type, by_dtype
15+
by_dtypes = [('PyObjectHashTable', 'object'), ('Int64HashTable', 'int64_t')]
2116

2217
# on_dtype
2318
on_dtypes = ['uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
@@ -29,7 +24,7 @@ on_dtypes = ['uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
2924

3025
from hashtable cimport *
3126

32-
{{for by_dtype, table_type, init_table, s1, s2, s3, g1, g2 in by_dtypes}}
27+
{{for table_type, by_dtype in by_dtypes}}
3328
{{for on_dtype in on_dtypes}}
3429

3530

@@ -59,7 +54,7 @@ def asof_join_{{on_dtype}}_by_{{by_dtype}}(ndarray[{{on_dtype}}] left_values,
5954
left_indexer = np.empty(left_size, dtype=np.int64)
6055
right_indexer = np.empty(left_size, dtype=np.int64)
6156

62-
hash_table = {{init_table}}
57+
hash_table = {{table_type}}(right_size)
6358

6459
right_pos = 0
6560
for left_pos in range(left_size):
@@ -71,18 +66,18 @@ def asof_join_{{on_dtype}}_by_{{by_dtype}}(ndarray[{{on_dtype}}] left_values,
7166
if allow_exact_matches:
7267
while right_pos < right_size and\
7368
right_values[right_pos] <= left_values[left_pos]:
74-
hash_table{{s1}}right_by_values[right_pos]{{s2}}right_pos{{s3}}
69+
hash_table.set_item(right_by_values[right_pos], right_pos)
7570
right_pos += 1
7671
else:
7772
while right_pos < right_size and\
7873
right_values[right_pos] < left_values[left_pos]:
79-
hash_table{{s1}}right_by_values[right_pos]{{s2}}right_pos{{s3}}
74+
hash_table.set_item(right_by_values[right_pos], right_pos)
8075
right_pos += 1
8176
right_pos -= 1
8277

8378
# save positions as the desired index
8479
by_value = left_by_values[left_pos]
85-
found_right_pos = hash_table{{g1}}by_value{{g2}}\
80+
found_right_pos = hash_table.get_item(by_value)\
8681
if by_value in hash_table else -1
8782
left_indexer[left_pos] = left_pos
8883
right_indexer[left_pos] = found_right_pos

0 commit comments

Comments
 (0)