Skip to content

Commit 5d15520

Browse files
authored
CLN: simplify take tempita output (#42263)
1 parent d8041ca commit 5d15520

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

pandas/_libs/algos_take_helper.pxi.in

+21-20
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,33 @@ def take_2d_axis0_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=2] values,
109109
cdef:
110110
Py_ssize_t i, j, k, n, idx
111111
{{c_type_out}} fv
112+
{{if c_type_in == c_type_out != "object"}}
113+
const {{c_type_out}} *v
114+
{{c_type_out}} *o
115+
{{endif}}
112116

113117
n = len(indexer)
114118
k = values.shape[1]
115119

116120
fv = fill_value
117121

118-
IF {{True if c_type_in == c_type_out != "object" else False}}:
119-
cdef:
120-
const {{c_type_out}} *v
121-
{{c_type_out}} *o
122-
123-
# GH#3130
124-
if (values.strides[1] == out.strides[1] and
125-
values.strides[1] == sizeof({{c_type_out}}) and
126-
sizeof({{c_type_out}}) * n >= 256):
127-
128-
for i in range(n):
129-
idx = indexer[i]
130-
if idx == -1:
131-
for j in range(k):
132-
out[i, j] = fv
133-
else:
134-
v = &values[idx, 0]
135-
o = &out[i, 0]
136-
memmove(o, v, <size_t>(sizeof({{c_type_out}}) * k))
137-
return
122+
{{if c_type_in == c_type_out != "object"}}
123+
# GH#3130
124+
if (values.strides[1] == out.strides[1] and
125+
values.strides[1] == sizeof({{c_type_out}}) and
126+
sizeof({{c_type_out}}) * n >= 256):
127+
128+
for i in range(n):
129+
idx = indexer[i]
130+
if idx == -1:
131+
for j in range(k):
132+
out[i, j] = fv
133+
else:
134+
v = &values[idx, 0]
135+
o = &out[i, 0]
136+
memmove(o, v, <size_t>(sizeof({{c_type_out}}) * k))
137+
return
138+
{{endif}}
138139

139140
for i in range(n):
140141
idx = indexer[i]

0 commit comments

Comments
 (0)