Skip to content

Commit 2535cbd

Browse files
jorisvandenbosschevladu
authored andcommitted
PERF: increase the minimum number of elements to use numexpr for ops from 1e4 to 1e6 (pandas-dev#40609)
1 parent bd793f4 commit 2535cbd

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

pandas/core/computation/expressions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939

4040
# the minimum prod shape that we will use numexpr
41-
_MIN_ELEMENTS = 10000
41+
_MIN_ELEMENTS = 1_000_000
4242

4343

4444
def set_use_numexpr(v=True):

pandas/tests/test_expressions.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ class TestExpressions:
4848
def setup_method(self, method):
4949

5050
self.frame = _frame.copy()
51-
self.array = _array.copy()
5251
self.frame2 = _frame2.copy()
53-
self.array2 = _array2.copy()
5452
self.mixed = _mixed.copy()
5553
self.mixed2 = _mixed2.copy()
5654
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
@@ -138,23 +136,19 @@ def test_arithmetic(self, df, flex):
138136
self.run_frame(df, df, flex)
139137

140138
def test_invalid(self):
139+
array = np.random.randn(1_000_001)
140+
array2 = np.random.randn(100)
141141

142142
# no op
143-
result = expr._can_use_numexpr(
144-
operator.add, None, self.array, self.array, "evaluate"
145-
)
143+
result = expr._can_use_numexpr(operator.add, None, array, array, "evaluate")
146144
assert not result
147145

148146
# min elements
149-
result = expr._can_use_numexpr(
150-
operator.add, "+", self.array2, self.array2, "evaluate"
151-
)
147+
result = expr._can_use_numexpr(operator.add, "+", array2, array2, "evaluate")
152148
assert not result
153149

154150
# ok, we only check on first part of expression
155-
result = expr._can_use_numexpr(
156-
operator.add, "+", self.array, self.array2, "evaluate"
157-
)
151+
result = expr._can_use_numexpr(operator.add, "+", array, array2, "evaluate")
158152
assert result
159153

160154
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)