Skip to content

Commit f9a079a

Browse files
authored
CLN: Use new hashtables in libindex to avoid casting (#37994)
1 parent caf751f commit f9a079a

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

pandas/_libs/index_class_helper.pxi.in

+14-16
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
1010

1111
{{py:
1212

13-
# name, dtype, hashtable_name
14-
dtypes = [('Float64', 'float64', 'Float64'),
15-
('Float32', 'float32', 'Float64'),
16-
('Int64', 'int64', 'Int64'),
17-
('Int32', 'int32', 'Int64'),
18-
('Int16', 'int16', 'Int64'),
19-
('Int8', 'int8', 'Int64'),
20-
('UInt64', 'uint64', 'UInt64'),
21-
('UInt32', 'uint32', 'UInt64'),
22-
('UInt16', 'uint16', 'UInt64'),
23-
('UInt8', 'uint8', 'UInt64'),
13+
# name, dtype
14+
dtypes = [('Float64', 'float64'),
15+
('Float32', 'float32'),
16+
('Int64', 'int64'),
17+
('Int32', 'int32'),
18+
('Int16', 'int16'),
19+
('Int8', 'int8'),
20+
('UInt64', 'uint64'),
21+
('UInt32', 'uint32'),
22+
('UInt16', 'uint16'),
23+
('UInt8', 'uint8'),
2424
]
2525
}}
2626

27-
{{for name, dtype, hashtable_name in dtypes}}
27+
{{for name, dtype in dtypes}}
2828

2929

3030
cdef class {{name}}Engine(IndexEngine):
3131
# constructor-caller is responsible for ensuring that vgetter()
3232
# returns an ndarray with dtype {{dtype}}_t
3333

3434
cdef _make_hash_table(self, Py_ssize_t n):
35-
return _hash.{{hashtable_name}}HashTable(n)
35+
return _hash.{{name}}HashTable(n)
3636

3737
{{if name not in {'Float64', 'Float32'} }}
3838
cdef _check_type(self, object val):
@@ -41,9 +41,7 @@ cdef class {{name}}Engine(IndexEngine):
4141
{{endif}}
4242

4343
cdef void _call_map_locations(self, values):
44-
# self.mapping is of type {{hashtable_name}}HashTable,
45-
# so convert dtype of values
46-
self.mapping.map_locations(algos.ensure_{{hashtable_name.lower()}}(values))
44+
self.mapping.map_locations(algos.ensure_{{name.lower()}}(values))
4745

4846
cdef _maybe_get_bool_indexer(self, object val):
4947
cdef:

0 commit comments

Comments
 (0)