@@ -13,7 +13,7 @@ from pandas._libs.tslibs.util cimport get_c_string
13
13
14
14
{{py:
15
15
16
- # name, dtype, arg
16
+ # name, dtype, c_type
17
17
# the generated StringVector is not actually used
18
18
# but is included for completeness (rather ObjectVector is used
19
19
# for uniques in hashtables)
@@ -24,13 +24,13 @@ dtypes = [('Float64', 'float64', 'float64_t'),
24
24
('UInt64', 'uint64', 'uint64_t')]
25
25
}}
26
26
27
- {{for name, dtype, arg in dtypes}}
27
+ {{for name, dtype, c_type in dtypes}}
28
28
29
29
30
30
{{if dtype != 'int64'}}
31
31
32
32
ctypedef struct {{name}}VectorData:
33
- {{arg }} *data
33
+ {{c_type }} *data
34
34
Py_ssize_t n, m
35
35
36
36
{{endif}}
@@ -39,7 +39,7 @@ ctypedef struct {{name}}VectorData:
39
39
@cython.wraparound(False)
40
40
@cython.boundscheck(False)
41
41
cdef inline void append_data_{{dtype}}({{name}}VectorData *data,
42
- {{arg }} x) nogil:
42
+ {{c_type }} x) nogil:
43
43
44
44
data.data[data.n] = x
45
45
data.n += 1
@@ -61,14 +61,14 @@ cdef inline bint needs_resize(vector_data *data) nogil:
61
61
62
62
{{py:
63
63
64
- # name, dtype, arg, idtype
65
- dtypes = [('Float64', 'float64', 'float64_t', 'np.float64' ),
66
- ('UInt64', 'uint64', 'uint64_t', 'np.uint64' ),
67
- ('Int64', 'int64', 'int64_t', 'np.int64' )]
64
+ # name, dtype, c_type
65
+ dtypes = [('Float64', 'float64', 'float64_t'),
66
+ ('UInt64', 'uint64', 'uint64_t'),
67
+ ('Int64', 'int64', 'int64_t')]
68
68
69
69
}}
70
70
71
- {{for name, dtype, arg, idtype in dtypes}}
71
+ {{for name, dtype, c_type in dtypes}}
72
72
73
73
cdef class {{name}}Vector:
74
74
@@ -87,13 +87,13 @@ cdef class {{name}}Vector:
87
87
self.external_view_exists = False
88
88
self.data.n = 0
89
89
self.data.m = _INIT_VEC_CAP
90
- self.ao = np.empty(self.data.m, dtype={{idtype }})
91
- self.data.data = <{{arg }}*>self.ao.data
90
+ self.ao = np.empty(self.data.m, dtype=np.{{dtype }})
91
+ self.data.data = <{{c_type }}*>self.ao.data
92
92
93
93
cdef resize(self):
94
94
self.data.m = max(self.data.m * 4, _INIT_VEC_CAP)
95
95
self.ao.resize(self.data.m, refcheck=False)
96
- self.data.data = <{{arg }}*>self.ao.data
96
+ self.data.data = <{{c_type }}*>self.ao.data
97
97
98
98
def __dealloc__(self):
99
99
if self.data is not NULL:
@@ -113,7 +113,7 @@ cdef class {{name}}Vector:
113
113
self.external_view_exists = True
114
114
return self.ao
115
115
116
- cdef inline void append(self, {{arg }} x):
116
+ cdef inline void append(self, {{c_type }} x):
117
117
118
118
if needs_resize(self.data):
119
119
if self.external_view_exists:
@@ -123,7 +123,7 @@ cdef class {{name}}Vector:
123
123
124
124
append_data_{{dtype}}(self.data, x)
125
125
126
- cdef extend(self, const {{arg }}[:] x):
126
+ cdef extend(self, const {{c_type }}[:] x):
127
127
for i in range(len(x)):
128
128
self.append(x[i])
129
129
@@ -279,7 +279,8 @@ cdef class {{name}}HashTable(HashTable):
279
279
self.table = NULL
280
280
281
281
def __contains__(self, object key):
282
- cdef khiter_t k
282
+ cdef:
283
+ khiter_t k
283
284
k = kh_get_{{dtype}}(self.table, key)
284
285
return k != self.table.n_buckets
285
286
@@ -290,7 +291,8 @@ cdef class {{name}}HashTable(HashTable):
290
291
sizeof(uint32_t)) # flags
291
292
292
293
cpdef get_item(self, {{dtype}}_t val):
293
- cdef khiter_t k
294
+ cdef:
295
+ khiter_t k
294
296
k = kh_get_{{dtype}}(self.table, val)
295
297
if k != self.table.n_buckets:
296
298
return self.table.vals[k]
@@ -899,7 +901,8 @@ cdef class PyObjectHashTable(HashTable):
899
901
return self.table.size
900
902
901
903
def __contains__(self, object key):
902
- cdef khiter_t k
904
+ cdef:
905
+ khiter_t k
903
906
hash(key)
904
907
905
908
k = kh_get_pymap(self.table, <PyObject*>key)
@@ -912,7 +915,8 @@ cdef class PyObjectHashTable(HashTable):
912
915
sizeof(uint32_t)) # flags
913
916
914
917
cpdef get_item(self, object val):
915
- cdef khiter_t k
918
+ cdef:
919
+ khiter_t k
916
920
917
921
k = kh_get_pymap(self.table, <PyObject*>val)
918
922
if k != self.table.n_buckets:
0 commit comments