Skip to content

Commit ab8541c

Browse files
Backport PR #57454 on branch 2.2.x (Release the gil in take for axis=1) (#57484)
Backport PR #57454: Release the gil in take for axis=1 Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 32d2b99 commit ab8541c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/_libs/algos_take_helper.pxi.in

+12
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ def take_2d_axis1_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=2] values,
184184

185185
fv = fill_value
186186

187+
{{if c_type_in == c_type_out != "object"}}
188+
with nogil:
189+
for i in range(n):
190+
for j in range(k):
191+
idx = indexer[j]
192+
if idx == -1:
193+
out[i, j] = fv
194+
else:
195+
out[i, j] = values[i, idx]
196+
197+
{{else}}
187198
for i in range(n):
188199
for j in range(k):
189200
idx = indexer[j]
@@ -195,6 +206,7 @@ def take_2d_axis1_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=2] values,
195206
{{else}}
196207
out[i, j] = values[i, idx]
197208
{{endif}}
209+
{{endif}}
198210

199211

200212
@cython.wraparound(False)

0 commit comments

Comments
 (0)