Skip to content

Commit b871012

Browse files
committed
extracting khash for primitive types into a helper-file
1 parent 8d1b8ab commit b871012

File tree

3 files changed

+77
-66
lines changed

3 files changed

+77
-66
lines changed

pandas/_libs/khash.pxd

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -67,72 +67,6 @@ cdef extern from "khash_python.h":
6767
void kh_destroy_str_starts(kh_str_starts_t*) nogil
6868
void kh_resize_str_starts(kh_str_starts_t*, khint_t) nogil
6969

70-
ctypedef struct kh_int64_t:
71-
khint_t n_buckets, size, n_occupied, upper_bound
72-
uint32_t *flags
73-
int64_t *keys
74-
size_t *vals
75-
76-
kh_int64_t* kh_init_int64() nogil
77-
void kh_destroy_int64(kh_int64_t*) nogil
78-
void kh_clear_int64(kh_int64_t*) nogil
79-
khint_t kh_get_int64(kh_int64_t*, int64_t) nogil
80-
void kh_resize_int64(kh_int64_t*, khint_t) nogil
81-
khint_t kh_put_int64(kh_int64_t*, int64_t, int*) nogil
82-
void kh_del_int64(kh_int64_t*, khint_t) nogil
83-
84-
bint kh_exist_int64(kh_int64_t*, khiter_t) nogil
85-
86-
ctypedef uint64_t khuint64_t
87-
88-
ctypedef struct kh_uint64_t:
89-
khint_t n_buckets, size, n_occupied, upper_bound
90-
uint32_t *flags
91-
khuint64_t *keys
92-
size_t *vals
93-
94-
kh_uint64_t* kh_init_uint64() nogil
95-
void kh_destroy_uint64(kh_uint64_t*) nogil
96-
void kh_clear_uint64(kh_uint64_t*) nogil
97-
khint_t kh_get_uint64(kh_uint64_t*, uint64_t) nogil
98-
void kh_resize_uint64(kh_uint64_t*, khint_t) nogil
99-
khint_t kh_put_uint64(kh_uint64_t*, uint64_t, int*) nogil
100-
void kh_del_uint64(kh_uint64_t*, khint_t) nogil
101-
102-
bint kh_exist_uint64(kh_uint64_t*, khiter_t) nogil
103-
104-
ctypedef struct kh_float64_t:
105-
khint_t n_buckets, size, n_occupied, upper_bound
106-
uint32_t *flags
107-
float64_t *keys
108-
size_t *vals
109-
110-
kh_float64_t* kh_init_float64() nogil
111-
void kh_destroy_float64(kh_float64_t*) nogil
112-
void kh_clear_float64(kh_float64_t*) nogil
113-
khint_t kh_get_float64(kh_float64_t*, float64_t) nogil
114-
void kh_resize_float64(kh_float64_t*, khint_t) nogil
115-
khint_t kh_put_float64(kh_float64_t*, float64_t, int*) nogil
116-
void kh_del_float64(kh_float64_t*, khint_t) nogil
117-
118-
bint kh_exist_float64(kh_float64_t*, khiter_t) nogil
119-
120-
ctypedef struct kh_int32_t:
121-
khint_t n_buckets, size, n_occupied, upper_bound
122-
uint32_t *flags
123-
int32_t *keys
124-
size_t *vals
125-
126-
kh_int32_t* kh_init_int32() nogil
127-
void kh_destroy_int32(kh_int32_t*) nogil
128-
void kh_clear_int32(kh_int32_t*) nogil
129-
khint_t kh_get_int32(kh_int32_t*, int32_t) nogil
130-
void kh_resize_int32(kh_int32_t*, khint_t) nogil
131-
khint_t kh_put_int32(kh_int32_t*, int32_t, int*) nogil
132-
void kh_del_int32(kh_int32_t*, khint_t) nogil
133-
134-
bint kh_exist_int32(kh_int32_t*, khiter_t) nogil
135-
13670
# sweep factorize
13771

13872
ctypedef struct kh_strbox_t:
@@ -150,3 +84,5 @@ cdef extern from "khash_python.h":
15084
void kh_del_strbox(kh_strbox_t*, khint_t) nogil
15185

15286
bint kh_exist_strbox(kh_strbox_t*, khiter_t) nogil
87+
88+
include "khash_for_primitive_helper.pxi"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""
2+
Template for wrapping khash-tables for each primitive `dtype`
3+
4+
WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
5+
"""
6+
7+
8+
9+
cdef extern from "khash_python.h":
10+
ctypedef struct kh_int64_t:
11+
khint_t n_buckets, size, n_occupied, upper_bound
12+
uint32_t *flags
13+
int64_t *keys
14+
size_t *vals
15+
16+
kh_int64_t* kh_init_int64() nogil
17+
void kh_destroy_int64(kh_int64_t*) nogil
18+
void kh_clear_int64(kh_int64_t*) nogil
19+
khint_t kh_get_int64(kh_int64_t*, int64_t) nogil
20+
void kh_resize_int64(kh_int64_t*, khint_t) nogil
21+
khint_t kh_put_int64(kh_int64_t*, int64_t, int*) nogil
22+
void kh_del_int64(kh_int64_t*, khint_t) nogil
23+
24+
bint kh_exist_int64(kh_int64_t*, khiter_t) nogil
25+
26+
ctypedef uint64_t khuint64_t
27+
28+
ctypedef struct kh_uint64_t:
29+
khint_t n_buckets, size, n_occupied, upper_bound
30+
uint32_t *flags
31+
khuint64_t *keys
32+
size_t *vals
33+
34+
kh_uint64_t* kh_init_uint64() nogil
35+
void kh_destroy_uint64(kh_uint64_t*) nogil
36+
void kh_clear_uint64(kh_uint64_t*) nogil
37+
khint_t kh_get_uint64(kh_uint64_t*, uint64_t) nogil
38+
void kh_resize_uint64(kh_uint64_t*, khint_t) nogil
39+
khint_t kh_put_uint64(kh_uint64_t*, uint64_t, int*) nogil
40+
void kh_del_uint64(kh_uint64_t*, khint_t) nogil
41+
42+
bint kh_exist_uint64(kh_uint64_t*, khiter_t) nogil
43+
44+
ctypedef struct kh_float64_t:
45+
khint_t n_buckets, size, n_occupied, upper_bound
46+
uint32_t *flags
47+
float64_t *keys
48+
size_t *vals
49+
50+
kh_float64_t* kh_init_float64() nogil
51+
void kh_destroy_float64(kh_float64_t*) nogil
52+
void kh_clear_float64(kh_float64_t*) nogil
53+
khint_t kh_get_float64(kh_float64_t*, float64_t) nogil
54+
void kh_resize_float64(kh_float64_t*, khint_t) nogil
55+
khint_t kh_put_float64(kh_float64_t*, float64_t, int*) nogil
56+
void kh_del_float64(kh_float64_t*, khint_t) nogil
57+
58+
bint kh_exist_float64(kh_float64_t*, khiter_t) nogil
59+
60+
ctypedef struct kh_int32_t:
61+
khint_t n_buckets, size, n_occupied, upper_bound
62+
uint32_t *flags
63+
int32_t *keys
64+
size_t *vals
65+
66+
kh_int32_t* kh_init_int32() nogil
67+
void kh_destroy_int32(kh_int32_t*) nogil
68+
void kh_clear_int32(kh_int32_t*) nogil
69+
khint_t kh_get_int32(kh_int32_t*, int32_t) nogil
70+
void kh_resize_int32(kh_int32_t*, khint_t) nogil
71+
khint_t kh_put_int32(kh_int32_t*, int32_t, int*) nogil
72+
void kh_del_int32(kh_int32_t*, khint_t) nogil
73+
74+
bint kh_exist_int32(kh_int32_t*, khiter_t) nogil

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def is_platform_mac():
5353
"hashtable": [
5454
"_libs/hashtable_class_helper.pxi.in",
5555
"_libs/hashtable_func_helper.pxi.in",
56+
"_libs/khash_for_primitive_helper.pxi.in",
5657
],
5758
"index": ["_libs/index_class_helper.pxi.in"],
5859
"sparse": ["_libs/sparse_op_helper.pxi.in"],

0 commit comments

Comments
 (0)