Skip to content

Commit aa87ec9

Browse files
qwhelanPingviinituutti
authored andcommitted
PERF: provide additional type information to compiler in maybe_convert_objects (pandas-dev#24647)
1 parent 9bc6f0c commit aa87ec9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

asv_bench/benchmarks/ctors.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def list_of_lists_with_none(arr):
4141

4242
class SeriesConstructors(object):
4343

44-
param_names = ["data_fmt", "with_index"]
44+
param_names = ["data_fmt", "with_index", "dtype"]
4545
params = [[no_change,
4646
list,
4747
list_of_str,
@@ -52,15 +52,19 @@ class SeriesConstructors(object):
5252
list_of_lists,
5353
list_of_tuples_with_none,
5454
list_of_lists_with_none],
55-
[False, True]]
55+
[False, True],
56+
['float', 'int']]
5657

57-
def setup(self, data_fmt, with_index):
58+
def setup(self, data_fmt, with_index, dtype):
5859
N = 10**4
59-
arr = np.random.randn(N)
60+
if dtype == 'float':
61+
arr = np.random.randn(N)
62+
else:
63+
arr = np.arange(N)
6064
self.data = data_fmt(arr)
6165
self.index = np.arange(N) if with_index else None
6266

63-
def time_series_constructor(self, data_fmt, with_index):
67+
def time_series_constructor(self, data_fmt, with_index, dtype):
6468
Series(self.data, index=self.index)
6569

6670

pandas/_libs/lib.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,8 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
20112011
floats[i] = <float64_t>val
20122012
complexes[i] = <double complex>val
20132013
if not seen.null_:
2014-
seen.saw_int(int(val))
2014+
val = int(val)
2015+
seen.saw_int(val)
20152016

20162017
if ((seen.uint_ and seen.sint_) or
20172018
val > oUINT64_MAX or val < oINT64_MIN):

0 commit comments

Comments
 (0)