@@ -13,7 +13,7 @@ from pandas._libs.tslibs.util cimport get_c_string
1313
1414{{py:
1515
16- # name, dtype, arg
16+ # name, dtype, c_type
1717# the generated StringVector is not actually used
1818# but is included for completeness (rather ObjectVector is used
1919# for uniques in hashtables)
@@ -24,13 +24,13 @@ dtypes = [('Float64', 'float64', 'float64_t'),
2424 ('UInt64', 'uint64', 'uint64_t')]
2525}}
2626
27- {{for name, dtype, arg in dtypes}}
27+ {{for name, dtype, c_type in dtypes}}
2828
2929
3030{{if dtype != 'int64'}}
3131
3232ctypedef struct {{name}}VectorData:
33- {{arg }} *data
33+ {{c_type }} *data
3434 Py_ssize_t n, m
3535
3636{{endif}}
@@ -39,7 +39,7 @@ ctypedef struct {{name}}VectorData:
3939@cython.wraparound(False)
4040@cython.boundscheck(False)
4141cdef inline void append_data_{{dtype}}({{name}}VectorData *data,
42- {{arg }} x) nogil:
42+ {{c_type }} x) nogil:
4343
4444 data.data[data.n] = x
4545 data.n += 1
@@ -61,14 +61,14 @@ cdef inline bint needs_resize(vector_data *data) nogil:
6161
6262{{py:
6363
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')]
6868
6969}}
7070
71- {{for name, dtype, arg, idtype in dtypes}}
71+ {{for name, dtype, c_type in dtypes}}
7272
7373cdef class {{name}}Vector:
7474
@@ -87,13 +87,13 @@ cdef class {{name}}Vector:
8787 self.external_view_exists = False
8888 self.data.n = 0
8989 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
9292
9393 cdef resize(self):
9494 self.data.m = max(self.data.m * 4, _INIT_VEC_CAP)
9595 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
9797
9898 def __dealloc__(self):
9999 if self.data is not NULL:
@@ -113,7 +113,7 @@ cdef class {{name}}Vector:
113113 self.external_view_exists = True
114114 return self.ao
115115
116- cdef inline void append(self, {{arg }} x):
116+ cdef inline void append(self, {{c_type }} x):
117117
118118 if needs_resize(self.data):
119119 if self.external_view_exists:
@@ -123,7 +123,7 @@ cdef class {{name}}Vector:
123123
124124 append_data_{{dtype}}(self.data, x)
125125
126- cdef extend(self, const {{arg }}[:] x):
126+ cdef extend(self, const {{c_type }}[:] x):
127127 for i in range(len(x)):
128128 self.append(x[i])
129129
@@ -279,7 +279,8 @@ cdef class {{name}}HashTable(HashTable):
279279 self.table = NULL
280280
281281 def __contains__(self, object key):
282- cdef khiter_t k
282+ cdef:
283+ khiter_t k
283284 k = kh_get_{{dtype}}(self.table, key)
284285 return k != self.table.n_buckets
285286
@@ -290,7 +291,8 @@ cdef class {{name}}HashTable(HashTable):
290291 sizeof(uint32_t)) # flags
291292
292293 cpdef get_item(self, {{dtype}}_t val):
293- cdef khiter_t k
294+ cdef:
295+ khiter_t k
294296 k = kh_get_{{dtype}}(self.table, val)
295297 if k != self.table.n_buckets:
296298 return self.table.vals[k]
@@ -899,7 +901,8 @@ cdef class PyObjectHashTable(HashTable):
899901 return self.table.size
900902
901903 def __contains__(self, object key):
902- cdef khiter_t k
904+ cdef:
905+ khiter_t k
903906 hash(key)
904907
905908 k = kh_get_pymap(self.table, <PyObject*>key)
@@ -912,7 +915,8 @@ cdef class PyObjectHashTable(HashTable):
912915 sizeof(uint32_t)) # flags
913916
914917 cpdef get_item(self, object val):
915- cdef khiter_t k
918+ cdef:
919+ khiter_t k
916920
917921 k = kh_get_pymap(self.table, <PyObject*>val)
918922 if k != self.table.n_buckets:
0 commit comments