REF: simplify sanitize_array
State: closed

We end up calling _try_cast in 3 places instead of 5

Labels:
name: Refactor
description: Internal refactoring of code

Comments:
does this give any perf improvement?
thanks, pls post perf if you can.
will run asvs; will try to see if we have ones that go down all the affected paths
with `-b ctors`

```
       before           after         ratio
     [99ec78ca]       [2085c19f]
     <master~2>       <ref-sanitize>
+        660±60μs         754±80μs     1.14  ctors.SeriesConstructors.time_series_constructor(<function list_of_str at 0x127049f70>, False, 'float')
+        644±60μs         691±90μs     1.07  ctors.SeriesConstructors.time_series_constructor(<function list_of_str at 0x127049f70>, False, 'int')
+        658±50μs         694±90μs     1.05  ctors.SeriesConstructors.time_series_constructor(<function list_of_str at 0x127049f70>, True, 'float')
+      3.18±0.3ms       3.21±0.2ms     1.01  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x1270244c0>, True, 'int')
-     2.55±0.04ms       2.50±0.1ms     0.98  ctors.SeriesConstructors.time_series_constructor(<class 'list'>, False, 'int')
-        55.1±4μs         53.8±3μs     0.98  ctors.SeriesConstructors.time_series_constructor(<function no_change at 0x127049dc0>, False, 'int')
-      3.62±0.3ms       3.52±0.2ms     0.97  ctors.SeriesConstructors.time_series_constructor(<function arr_dict at 0x1270240d0>, True, 'int')
-      2.37±0.1ms       2.27±0.2ms     0.96  ctors.SeriesConstructors.time_series_constructor(<function arr_dict at 0x1270240d0>, False, 'float')
-        64.2±7μs         61.6±5μs     0.96  ctors.SeriesConstructors.time_series_constructor(<function no_change at 0x127049dc0>, True, 'float')
-      2.46±0.1ms       2.36±0.2ms     0.96  ctors.SeriesConstructors.time_series_constructor(<function arr_dict at 0x1270240d0>, True, 'float')
-      3.64±0.4ms       3.45±0.2ms     0.95  ctors.SeriesConstructors.time_series_constructor(<function arr_dict at 0x1270240d0>, False, 'int')
-      2.99±0.3ms       2.83±0.3ms     0.95  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists at 0x1270243a0>, True, 'float')
-      4.55±0.2ms       4.28±0.2ms     0.94  ctors.SeriesConstructors.time_series_constructor(<function gen_of_str at 0x127024040>, False, 'float')
-      4.26±0.1ms       3.95±0.3ms     0.93  ctors.SeriesConstructors.time_series_constructor(<function gen_of_str at 0x127024040>, False, 'int')
-      3.16±0.1ms       2.85±0.3ms     0.90  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x1270244c0>, False, 'int')
-      3.19±0.6ms       2.86±0.3ms     0.90  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x1270244c0>, False, 'float')
-      3.00±0.3ms       2.69±0.2ms     0.90  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists at 0x1270243a0>, True, 'int')
-      3.20±0.3ms       2.85±0.3ms     0.89  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples_with_none at 0x127024430>, False, 'int')
-      3.16±0.3ms       2.81±0.2ms     0.89  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x1270244c0>, True, 'float')
-      4.49±0.2ms       3.98±0.2ms     0.89  ctors.SeriesConstructors.time_series_constructor(<function gen_of_tuples at 0x127024310>, False, 'float')
-      3.20±0.3ms       2.81±0.3ms     0.88  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples_with_none at 0x127024430>, False, 'float')
-      3.09±0.3ms       2.70±0.1ms     0.87  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists at 0x1270243a0>, False, 'int')
-      3.09±0.2ms       2.70±0.2ms     0.87  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples at 0x127024280>, False, 'int')
-      3.13±0.2ms       2.72±0.1ms     0.87  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples at 0x127024280>, True, 'int')
-      3.15±0.3ms       2.69±0.1ms     0.86  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists at 0x1270243a0>, False, 'float')
-      4.57±0.4ms       3.87±0.1ms     0.85  ctors.SeriesConstructors.time_series_constructor(<function gen_of_tuples at 0x127024310>, False, 'int')
-      3.23±0.3ms       2.69±0.1ms     0.83  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples at 0x127024280>, True, 'float')
```