Skip to content

Commit

Permalink
Backport PR pandas-dev#57454 on branch 2.2.x (Release the gil in take…
Browse files Browse the repository at this point in the history
… for axis=1) (pandas-dev#57484)

Backport PR pandas-dev#57454: Release the gil in take for axis=1

Co-authored-by: Patrick Hoefler <[email protected]>
  • Loading branch information
meeseeksmachine and phofl authored Feb 18, 2024
1 parent 32d2b99 commit ab8541c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pandas/_libs/algos_take_helper.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ def take_2d_axis1_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=2] values,

fv = fill_value

{{if c_type_in == c_type_out != "object"}}
with nogil:
for i in range(n):
for j in range(k):
idx = indexer[j]
if idx == -1:
out[i, j] = fv
else:
out[i, j] = values[i, idx]

{{else}}
for i in range(n):
for j in range(k):
idx = indexer[j]
Expand All @@ -195,6 +206,7 @@ def take_2d_axis1_{{name}}_{{dest}}(ndarray[{{c_type_in}}, ndim=2] values,
{{else}}
out[i, j] = values[i, idx]
{{endif}}
{{endif}}


@cython.wraparound(False)
Expand Down

0 comments on commit ab8541c

Please sign in to comment.