Skip to content
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

PERF: O(n) speedup in any/all by re-enabling short-circuiting for bool case #25070

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions asv_bench/benchmarks/series_methods.py
Original file line number Diff line number Diff line change
@@ -201,4 +201,46 @@ def time_series_datetimeindex_repr(self):
getattr(self.s, 'a', None)


class All(object):

params = [[10**3, 10**6], ['fast', 'slow']]
param_names = ['N', 'case']

def setup(self, N, case):
val = case != 'fast'
self.s = Series([val] * N)

def time_all(self, N, case):
self.s.all()


class Any(object):

params = [[10**3, 10**6], ['fast', 'slow']]
param_names = ['N', 'case']

def setup(self, N, case):
val = case == 'fast'
self.s = Series([val] * N)

def time_any(self, N, case):
self.s.any()


class NanOps(object):

params = [['var', 'mean', 'median', 'max', 'min', 'sum', 'std', 'sem',
'argmax', 'skew', 'kurt', 'prod'],
[10**3, 10**6],
['int8', 'int32', 'int64', 'float64']]
param_names = ['func', 'N', 'dtype']

def setup(self, func, N, dtype):
self.s = Series([1] * N, dtype=dtype)
self.func = getattr(self.s, func)

def time_func(self, func, N, dtype):
self.func()


from .pandas_vb_common import setup # noqa: F401
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
@@ -247,6 +247,7 @@ Performance Improvements
- Imporved performance of :meth:`IntervalIndex.is_monotonic`, :meth:`IntervalIndex.is_monotonic_increasing` and :meth:`IntervalIndex.is_monotonic_decreasing` by removing conversion to :class:`MultiIndex` (:issue:`24813`)
- Improved performance of :meth:`DataFrame.to_csv` when writing datetime dtypes (:issue:`25708`)
- Improved performance of :meth:`read_csv` by much faster parsing of ``MM/YYYY`` and ``DD/MM/YYYY`` datetime formats (:issue:`25922`)
- Improved performance of nanops for dtypes that cannot store NaNs. Speedup is particularly prominent for :meth:`Series.all` and :meth:`Series.any` (:issue:`25070`)

.. _whatsnew_0250.bug_fixes:

Loading