Skip to content

Commit 0f215ad

Browse files
committed
PERF: consolidate imports inside parse_time_string
1 parent 3fe697f commit 0f215ad

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

asv_bench/benchmarks/period.py

+4
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ class PeriodIndexConstructor(object):
4343
def setup(self, freq):
4444
self.rng = date_range('1985', periods=1000)
4545
self.rng2 = date_range('1985', periods=1000).to_pydatetime()
46+
self.ints = list(range(2000, 3000))
4647

4748
def time_from_date_range(self, freq):
4849
PeriodIndex(self.rng, freq=freq)
4950

5051
def time_from_pydatetime(self, freq):
5152
PeriodIndex(self.rng2, freq=freq)
5253

54+
def time_from_ints(self, freq):
55+
PeriodIndex(self.ints, freq=freq)
56+
5357

5458
class DataFramePeriodColumn(object):
5559

pandas/_libs/tslibs/parsing.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
118118
if getattr(freq, "_typ", None) == "dateoffset":
119119
freq = freq.rule_code
120120

121-
if dayfirst is None:
121+
if dayfirst is None or yearfirst is None:
122122
from pandas.core.config import get_option
123-
dayfirst = get_option("display.date_dayfirst")
124-
if yearfirst is None:
125-
from pandas.core.config import get_option
126-
yearfirst = get_option("display.date_yearfirst")
123+
if dayfirst is None:
124+
dayfirst = get_option("display.date_dayfirst")
125+
if yearfirst is None:
126+
yearfirst = get_option("display.date_yearfirst")
127127

128128
res = parse_datetime_string_with_reso(arg, freq=freq,
129129
dayfirst=dayfirst,

0 commit comments

Comments
 (0)