Skip to content

CLN: Use new hashtables in libindex to avoid casting #37994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions pandas/_libs/index_class_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in

{{py:

# name, dtype, hashtable_name
dtypes = [('Float64', 'float64', 'Float64'),
('Float32', 'float32', 'Float64'),
('Int64', 'int64', 'Int64'),
('Int32', 'int32', 'Int64'),
('Int16', 'int16', 'Int64'),
('Int8', 'int8', 'Int64'),
('UInt64', 'uint64', 'UInt64'),
('UInt32', 'uint32', 'UInt64'),
('UInt16', 'uint16', 'UInt64'),
('UInt8', 'uint8', 'UInt64'),
# name, dtype
dtypes = [('Float64', 'float64'),
('Float32', 'float32'),
('Int64', 'int64'),
('Int32', 'int32'),
('Int16', 'int16'),
('Int8', 'int8'),
('UInt64', 'uint64'),
('UInt32', 'uint32'),
('UInt16', 'uint16'),
('UInt8', 'uint8'),
]
}}

{{for name, dtype, hashtable_name in dtypes}}
{{for name, dtype in dtypes}}


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

cdef _make_hash_table(self, Py_ssize_t n):
return _hash.{{hashtable_name}}HashTable(n)
return _hash.{{name}}HashTable(n)

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

cdef void _call_map_locations(self, values):
# self.mapping is of type {{hashtable_name}}HashTable,
# so convert dtype of values
self.mapping.map_locations(algos.ensure_{{hashtable_name.lower()}}(values))
self.mapping.map_locations(algos.ensure_{{name.lower()}}(values))

cdef _maybe_get_bool_indexer(self, object val):
cdef:
Expand Down