Skip to content

Commit

Permalink
PERF: speed up tz-aware datetimearray ops by skipping useless validation
Browse files Browse the repository at this point in the history
  • Loading branch information
qwhelan committed Dec 30, 2018
1 parent 02a97c0 commit e935829
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.rst
Expand Up @@ -1295,6 +1295,7 @@ Performance Improvements
- Improved performance of iterating over a :class:`Series`. Using :meth:`DataFrame.itertuples` now creates iterators
without internally allocating lists of all elements (:issue:`20783`)
- Improved performance of :class:`Period` constructor, additionally benefitting ``PeriodArray`` and ``PeriodIndex`` creation (:issue:`24084` and :issue:`24118`)
- Improved performance of tz-aware :class:`DatetimeArray` binary operations (:issue:`24491`)

.. _whatsnew_0240.docs:

Expand Down
4 changes: 3 additions & 1 deletion pandas/core/arrays/datetimes.py
Expand Up @@ -262,7 +262,9 @@ def _from_sequence(cls, data, dtype=None, copy=False,
cls._validate_frequency(result, freq, ambiguous=ambiguous)

elif freq_infer:
result.freq = to_offset(result.inferred_freq)
# Set _freq directly to bypass duplicative _validate_frequency
# check.
result._freq = to_offset(result.inferred_freq)

return result

Expand Down
4 changes: 3 additions & 1 deletion pandas/core/arrays/timedeltas.py
Expand Up @@ -181,7 +181,9 @@ def _from_sequence(cls, data, dtype=_TD_DTYPE, copy=False,
cls._validate_frequency(result, freq)

elif freq_infer:
result.freq = to_offset(result.inferred_freq)
# Set _freq directly to bypass duplicative _validate_frequency
# check.
result._freq = to_offset(result.inferred_freq)

return result

Expand Down

0 comments on commit e935829

Please sign in to comment.