wesm commented on pull request #7442:
URL: https://github.com/apache/arrow/pull/7442#issuecomment-644513681
To show some simple numbers to show the perf before and after in Python,
this example has a high selectivity (all but one value selected) and low
selectivity filter (only 1% of values selected):
```
import numpy as np
import pandas as pd
import pyarrow as pa
import pyarrow.compute as pc
string_values = pa.array([pd.util.testing.rands(16)
for i in range(10000)] * 100)
double_values = pa.array(np.random.randn(1000000))
all_but_one = np.ones(len(string_values), dtype=bool)
all_but_one[500000] = False
only_1pct = np.array(np.random.binomial(1, 0.01, size=1000000), dtype=bool)
```
before:
```
In [4]: timeit pc.filter(double_values, only_1pct)
2.01 ms ± 7.89 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [5]: timeit pc.filter(double_values, all_but_one)
5.74 ms ± 17.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [6]: timeit pc.filter(string_values, only_1pct)
2.21 ms ± 6.87 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [7]: timeit pc.filter(string_values, all_but_one)
11.4 ms ± 142 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
```
after
```
In [29]: timeit pc.filter(double_values, only_1pct)
1.43 ms ± 3.79 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [30]: timeit pc.filter(double_values, all_but_one)
1.81 ms ± 20.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [31]: timeit pc.filter(string_values, only_1pct)
1.57 ms ± 4.06 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
In [32]: timeit pc.filter(string_values, all_but_one)
6.66 ms ± 39.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]