Skip to content

REF: _try_cast; go through fastpath more often #41597

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

Merged
merged 7 commits into from
May 22, 2021

Conversation

jbrockmendel
Copy link
Member

@simonjayhawkins simonjayhawkins added Performance Memory or execution speed performance Constructors Series/DataFrame/Index/pd.array Constructors Series Series data structure labels May 21, 2021
@simonjayhawkins
Copy link
Member

can you post benchmark results

@jreback jreback added this to the 1.3 milestone May 21, 2021
if is_object_dtype(dtype) and not isinstance(arr, np.ndarray):
subarr = construct_1d_object_array_from_listlike(arr)
return subarr
elif is_object_dtype(dtype):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could do this check upfront and assign to a variable (as do this at the top)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. might as well optimize to the gills

@jbrockmendel
Copy link
Member Author

with -b ctors

       before           after         ratio
     [6dff995e]       [29848ac6]
     <master>         <ref-cast>
+     2.67±0.05ms       2.74±0.1ms     1.03  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples at 0x11c088670>, True, 'int')
+     2.66±0.05ms      2.69±0.09ms     1.01  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples_with_none at 0x11c088820>, True, 'float')
-     2.63±0.05ms      2.60±0.04ms     0.99  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x11c0888b0>, True, 'float')
-     2.62±0.05ms      2.59±0.05ms     0.99  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x11c0888b0>, False, 'float')
-     2.63±0.03ms      2.59±0.04ms     0.99  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists at 0x11c088790>, False, 'float')
-     2.64±0.05ms      2.60±0.04ms     0.98  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x11c0888b0>, False, 'int')
-     2.66±0.07ms      2.61±0.04ms     0.98  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists_with_none at 0x11c0888b0>, True, 'int')
-     2.65±0.07ms      2.59±0.04ms     0.98  ctors.SeriesConstructors.time_series_constructor(<function list_of_lists at 0x11c088790>, True, 'float')
-      3.51±0.1ms      3.38±0.08ms     0.96  ctors.SeriesConstructors.time_series_constructor(<function gen_of_str at 0x11c088550>, False, 'int')
-     2.73±0.08ms      2.62±0.04ms     0.96  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples_with_none at 0x11c088820>, True, 'int')
-        591±30μs         565±20μs     0.96  ctors.SeriesConstructors.time_series_constructor(<function list_of_str at 0x11c0884c0>, True, 'float')
-      2.77±0.1ms      2.65±0.06ms     0.96  ctors.SeriesConstructors.time_series_constructor(<function list_of_tuples at 0x11c088670>, False, 'int')
-      50.5±0.8μs         45.4±2μs     0.90  ctors.SeriesConstructors.time_series_constructor(<function no_change at 0x11c088430>, True, 'float')
-        43.0±2μs         37.4±2μs     0.87  ctors.SeriesConstructors.time_series_constructor(<function no_change at 0x11c088430>, False, 'float')
-      52.9±0.6μs         44.5±2μs     0.84  ctors.SeriesConstructors.time_series_constructor(<function no_change at 0x11c088430>, True, 'int')
-        45.5±1μs       36.6±0.2μs     0.81  ctors.SeriesConstructors.time_series_constructor(<function no_change at 0x11c088430>, False, 'int')

@jreback jreback merged commit 619446a into pandas-dev:master May 22, 2021
@jbrockmendel jbrockmendel deleted the ref-cast branch May 22, 2021 01:39
TLouf pushed a commit to TLouf/pandas that referenced this pull request Jun 1, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constructors Series/DataFrame/Index/pd.array Constructors Performance Memory or execution speed performance Series Series data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series construction: _try_cast typo, function often taking slow route?
3 participants