diff --git a/asv_bench/benchmarks/ctors.py b/asv_bench/benchmarks/ctors.py index 7c78fe7e7a177..9082b4186bfa4 100644 --- a/asv_bench/benchmarks/ctors.py +++ b/asv_bench/benchmarks/ctors.py @@ -41,7 +41,7 @@ def list_of_lists_with_none(arr): class SeriesConstructors(object): - param_names = ["data_fmt", "with_index"] + param_names = ["data_fmt", "with_index", "dtype"] params = [[no_change, list, list_of_str, @@ -52,15 +52,19 @@ class SeriesConstructors(object): list_of_lists, list_of_tuples_with_none, list_of_lists_with_none], - [False, True]] + [False, True], + ['float', 'int']] - def setup(self, data_fmt, with_index): + def setup(self, data_fmt, with_index, dtype): N = 10**4 - arr = np.random.randn(N) + if dtype == 'float': + arr = np.random.randn(N) + else: + arr = np.arange(N) self.data = data_fmt(arr) self.index = np.arange(N) if with_index else None - def time_series_constructor(self, data_fmt, with_index): + def time_series_constructor(self, data_fmt, with_index, dtype): Series(self.data, index=self.index) diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 6e6d35f00725c..85eb6c3421222 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -2011,7 +2011,8 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0, floats[i] = val complexes[i] = val if not seen.null_: - seen.saw_int(int(val)) + val = int(val) + seen.saw_int(val) if ((seen.uint_ and seen.sint_) or val > oUINT64_MAX or val < oINT64_MIN):