Skip to content

Commit bef52df

Browse files
stephenwliny-p
authored and
y-p
committed
PERF: Limit memmove to >= 256 bytes, relax contiguity requirements
(only the stride in the dimension of the copy matters)
1 parent 4411a29 commit bef52df

File tree

2 files changed

+618
-439
lines changed

2 files changed

+618
-439
lines changed

pandas/src/generate_code.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ def take_2d_axis0_%(name)s_%(dest)s(ndarray[%(c_type_in)s, ndim=2] values,
9393
cdef:
9494
%(c_type_out)s *v, *o
9595
96-
if values.flags.c_contiguous and out.flags.c_contiguous:
96+
#GH3130
97+
if (values.strides[1] == out.strides[1] and
98+
values.strides[1] == sizeof(%(c_type_out)s) and
99+
sizeof(%(c_type_out)s) * n >= 256):
100+
97101
for i from 0 <= i < n:
98102
idx = indexer[i]
99103
if idx == -1:
@@ -138,7 +142,11 @@ def take_2d_axis1_%(name)s_%(dest)s(ndarray[%(c_type_in)s, ndim=2] values,
138142
cdef:
139143
%(c_type_out)s *v, *o
140144
141-
if values.flags.f_contiguous and out.flags.f_contiguous:
145+
#GH3130
146+
if (values.strides[0] == out.strides[0] and
147+
values.strides[0] == sizeof(%(c_type_out)s) and
148+
sizeof(%(c_type_out)s) * n >= 256):
149+
142150
for j from 0 <= j < k:
143151
idx = indexer[j]
144152
if idx == -1:

0 commit comments

Comments
 (0)