-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Hand numpy-like arrays with is_list_like #39830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
znicholls
commented
Feb 16, 2021
•
edited
Loading
edited
- follows PERF: is_list_like #39852
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
@jreback let's try this again. This time just updating the single Fixes to How can I tell how big the performance hit is? |
for something like this usually do |
Ok In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: a1 = [1, 2, 3]
...: a2 = np.array([1, 2, 3])
...: a3 = np.array([1, 2, 3])[0]
In [4]: %timeit pd.api.types.is_list_like(a1)
412 ns ± 22 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) # master
624 ns ± 15.3 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) # pr
In [5]: %timeit pd.api.types.is_list_like(a2)
415 ns ± 20.4 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) # master
416 ns ± 13.3 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) # pr
In [6]: %timeit pd.api.types.is_list_like(a3)
485 ns ± 140 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) # master
446 ns ± 120 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) # pr Almost identical results to #35127 (comment). Using If we end up back at this comment #35127 (comment) then we are simply going in circles between that comment and this comment #35127 (comment) |
FYI #39852 which changes the bogey. Not sure if the c-function is better or worse for you. |
Thanks, that helps for sure (list slightly slower but might also be because I'm running lots of stuff at the moment...). I think we can include this without performance hits after #39852 then. |
334e69c
to
015e1e8
Compare
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
@znicholls Thanks for the PR. closing as stale. ping if you want to continue. |