diff options
author | MattHarrigan <harrigan.matthew@gmail.com> | 2016-10-26 11:01:05 -0400 |
---|---|---|
committer | MattHarrigan <harrigan.matthew@gmail.com> | 2016-10-26 11:01:05 -0400 |
commit | b0e66ad754c2a2efeb8c6f39418e5bb7d3e388c5 (patch) | |
tree | f0e1a000839e9ecb30903e0f21250d2ebc13c1be /numpy/lib/arraysetops.py | |
parent | 484827189756d45e6231bfd2cd3cf6db9c2993df (diff) | |
download | numpy-b0e66ad754c2a2efeb8c6f39418e5bb7d3e388c5.tar.gz |
ENH: fast track default kwargs for ediff1d
Special case to_begin and to_end both equal to None, avoiding
subsequent steps. Particulary faster for small arrays where
overhead plays a big role.
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r-- | numpy/lib/arraysetops.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index e63e09546..889415efe 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -81,6 +81,10 @@ def ediff1d(ary, to_end=None, to_begin=None): # force a 1d array ary = np.asanyarray(ary).ravel() + # fast track default case + if to_begin is None and to_end is None: + return ary[1:] - ary[:-1] + # get the length of the diff'd values l = len(ary) - 1 if l < 0: |