CLN: simplify libreduction
State: closed


Labels:
name: Refactor
description: Internal refactoring of code
name: Reduction Operations
description: sum, mean, min, max, etc.

Comments:
can you check perf. IIRC this was attempted to be changed previously and did impact things (ideally I do like this change).
lgtm minor point above.
perf should be improved as we are doing strictly less.  ill run some asvs to be on the safe side
with `-b groupby`

```
       before           after         ratio
     [34b0bdc5]       [9f635602]
     <ref-homogenize>       <cln-libreduction-3>
+        914±30μs      1.03±0.03ms     1.13  groupby.Categories.time_groupby_extra_cat_sort
+      39.3±0.6ms         41.8±1ms     1.06  groupby.GroupByCythonAgg.time_frame_agg('float64', 'max')
-         222±4μs          209±3μs     0.94  groupby.GroupByMethods.time_dtype_as_group('int', 'tail', 'direct')
-        978±10μs         919±30μs     0.94  groupby.GroupByMethods.time_dtype_as_group('int', 'pct_change', 'transformation')
-         299±3ms         281±20ms     0.94  rolling.GroupbyEWMEngine.time_groupby_mean('numba')
-         280±1μs         255±10μs     0.91  groupby.GroupByMethods.time_dtype_as_group('int', 'sum', 'transformation')
-         811±8ms         724±20ms     0.89  groupby.TransformEngine.time_dataframe_numba(True)
-     1.19±0.02ms      1.05±0.05ms     0.89  groupby.RankWithTies.time_rank_ties('int64', 'first')
-     2.08±0.01ms      1.84±0.04ms     0.89  rolling.ExpandingMethods.time_expanding_groupby('DataFrame', 'float', 'mean')
-     2.18±0.08ms       1.93±0.1ms     0.88  rolling.ExpandingMethods.time_expanding_groupby('Series', 'float', 'median')
-        795±10ms         700±10ms     0.88  groupby.TransformEngine.time_series_numba(True)
-         115±4μs          101±4μs     0.88  groupby.GroupByMethods.time_dtype_as_group('float', 'count', 'transformation')
-     2.33±0.05ms      2.04±0.05ms     0.88  rolling.ExpandingMethods.time_expanding_groupby('Series', 'float', 'count')
-     1.44±0.03ms      1.26±0.02ms     0.87  rolling.GroupbyEWM.time_groupby_method('var')
-     2.13±0.03ms      1.86±0.04ms     0.87  rolling.ExpandingMethods.time_expanding_groupby('Series', 'int', 'mean')
-        80.2±1ms       69.5±0.5ms     0.87  groupby.MultiColumn.time_col_select_lambda_sum
-         205±4μs          178±7μs     0.87  groupby.GroupByMethods.time_dtype_as_group('float', 'cumcount', 'direct')
-         271±6ms          234±7ms     0.86  groupby.Transform.time_transform_lambda_max
-     1.20±0.01ms      1.02±0.05ms     0.85  groupby.RankWithTies.time_rank_ties('float32', 'dense')
-        80.8±8ms         68.2±2ms     0.84  groupby.TransformEngine.time_dataframe_cython(False)
-     1.01±0.01ms         855±10μs     0.84  groupby.SumBools.time_groupby_sum_booleans
-         831±8μs         700±20μs     0.84  groupby.SumMultiLevel.time_groupby_sum_multiindex
-     2.10±0.04ms      1.77±0.04ms     0.84  rolling.ExpandingMethods.time_expanding_groupby('DataFrame', 'float', 'min')
-         200±5μs          168±4μs     0.84  groupby.GroupByMethods.time_dtype_as_group('float', 'tail', 'transformation')
-     2.16±0.04ms      1.81±0.07ms     0.84  rolling.ExpandingMethods.time_expanding_groupby('Series', 'float', 'sum')
-     2.36±0.03ms      1.96±0.04ms     0.83  rolling.ExpandingMethods.time_expanding_groupby('Series', 'int', 'count')
-      9.37±0.1ms       7.77±0.1ms     0.83  groupby.Categories.time_groupby_ordered_nosort
-     2.20±0.03ms      1.81±0.07ms     0.82  rolling.ExpandingMethods.time_expanding_groupby('DataFrame', 'float', 'sum')
-        252±20μs         206±10μs     0.82  groupby.GroupByMethods.time_dtype_as_group('int', 'tail', 'transformation')
-     1.19±0.02ms         966±30μs     0.81  groupby.RankWithTies.time_rank_ties('float32', 'max')
-     1.21±0.09ms         984±30μs     0.81  groupby.RankWithTies.time_rank_ties('float32', 'min')
-        116±20μs         93.4±4μs     0.81  groupby.GroupByMethods.time_dtype_as_group('float', 'cummin', 'transformation')
-     2.23±0.02ms      1.80±0.05ms     0.81  rolling.ExpandingMethods.time_expanding_groupby('Series', 'int', 'kurt')
-      5.12±0.4ms       4.09±0.1ms     0.80  rolling.GroupbyEWM.time_groupby_method('corr')
-        124±10μs         99.0±5μs     0.80  groupby.GroupByMethods.time_dtype_as_group('float', 'cumsum', 'transformation')
-     2.25±0.02ms      1.78±0.03ms     0.79  rolling.ExpandingMethods.time_expanding_groupby('Series', 'int', 'skew')
-        33.6±3ms         25.6±1ms     0.76  groupby.TransformEngine.time_series_cython(True)
-        15.0±2ms       11.5±0.3ms     0.76  groupby.Nth.time_frame_nth('float64')
-        114±10μs         86.8±1μs     0.76  groupby.GroupByMethods.time_dtype_as_group('float', 'cummax', 'direct')
-        137±10μs          104±4μs     0.76  groupby.GroupByMethods.time_dtype_as_group('object', 'size', 'direct')
-      37.4±0.8ms         28.5±2ms     0.76  rolling.Pairwise.time_groupby(None, 'cov', False)
-        114±10μs         85.6±3μs     0.75  groupby.GroupByMethods.time_dtype_as_group('float', 'cummax', 'transformation')
-         104±9ms         78.0±5ms     0.75  rolling.Pairwise.time_groupby(1000, 'cov', True)
-      8.15±0.7ms       6.03±0.2ms     0.74  groupby.Transform.time_transform_multi_key2
-        40.5±2ms       29.4±0.9ms     0.73  groupby.Nth.time_frame_nth_any('object')
-        332±50μs          241±5μs     0.73  groupby.GroupByMethods.time_dtype_as_group('float', 'prod', 'transformation')
-        469±60μs          340±9μs     0.72  groupby.GroupByMethods.time_dtype_as_group('float', 'quantile', 'direct')
-        11.3±1ms       7.97±0.2ms     0.70  groupby.Nth.time_series_nth('float64')
-        138±20μs         96.7±3μs     0.70  groupby.GroupByMethods.time_dtype_as_group('float', 'shift', 'transformation')
-        153±30μs          101±6μs     0.66  groupby.GroupByMethods.time_dtype_as_group('float', 'size', 'direct')
-        626±20μs         410±10μs     0.65  groupby.GroupByMethods.time_dtype_as_group('float', 'sem', 'direct')
-        156±40μs          102±3μs     0.65  groupby.GroupByMethods.time_dtype_as_group('float', 'shift', 'direct')
-        717±60μs         414±10μs     0.58  groupby.GroupByMethods.time_dtype_as_group('float', 'sem', 'transformation')
```

i expect mostly noise, but at least no clear slowdown
great