You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] If numpy is available use it for normalizing slice #46771
I've tested with both previous case and new case with the following results:
Previously to the PR using numpy:
In [2]: a=pa.array(np.arange(0, 2_000_000))
In [3]: %timeita[slice(1, 1_000_000, 2)]
763μs ± 4.28μsperloop (mean ± std. dev. of7runs, 1,000loopseach)
After the PR using Python object:
In [2]: a=pa.array(np.arange(0, 2_000_000))
In [3]: %timeita[slice(1, 1_000_000, 2)]
25.7ms ± 703μsperloop (mean ± std. dev. of7runs, 10loopseach)
We should probably use np.arange if numpy is available otherwise revert to using a Python object.
We could also potentially add the possibility for Array::Slice to have a step attribute being able to remove some of the custom code and just use step internally.
We should probably use np.arange if numpy is available otherwise revert to using a Python object.
Or, instead of exhibiting wildly different performance based on Numpy availability, perhaps we can implement a pa.arange function? It should relatively easy to do so in C++ (we can limit the output types to integer types for now).
Activity
pitrou commentedon Jun 10, 2025
Or, instead of exhibiting wildly different performance based on Numpy availability, perhaps we can implement a
pa.arangefunction? It should relatively easy to do so in C++ (we can limit the output types to integer types for now).GH-46771: [Python][C++] Implement pa.arange function to generate arra…
raulcd commentedon Jun 20, 2025
Issue resolved by pull request 46778
#46778