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
In [62]: %timeit com.is_integer(13)
1000000 loops, best of 3: 965 ns per loop
In [63]: %timeit com.is_integer(np.int32(2))
100000 loops, best of 3: 2.56 µs per loop
In [64]: %timeit com.is_integer(np.int64(2))
1000000 loops, best of 3: 1.27 µs per loop
In [65]: %timeit com.is_integer(14L)
1000000 loops, best of 3: 970 ns per loop
In [76]: %timeit com.is_integer("1")
1000000 loops, best of 3: 1.66 µs per loop
The lower bound of this function would be:
In [66]: %timeit type(3) is int
10000000 loops, best of 3: 85.8 ns per loop
My first attempt is the following which pulls the tuple creation out and optimizes for the common case of calling with int. This seems to make all cases faster, especially the common, int, case:
In [70]: %timeit is_integer(13)
10000000 loops, best of 3: 146 ns per loop
In [71]: %timeit is_integer(np.int32(2))
100000 loops, best of 3: 2.43 µs per loop
In [72]: %timeit is_integer(np.int64(2))
1000000 loops, best of 3: 375 ns per loop
In [73]: %timeit is_integer(14L)
1000000 loops, best of 3: 911 ns per loop
In [75]: %timeit is_integer("1")
1000000 loops, best of 3: 1.57 µs per loop
The text was updated successfully, but these errors were encountered:
Observe:
The lower bound of this function would be:
My first attempt is the following which pulls the tuple creation out and optimizes for the common case of calling with
int
. This seems to make all cases faster, especially the common,int
, case:and results:
The text was updated successfully, but these errors were encountered: