Skip to content

Commit 6430ab9

Browse files
committed
Re-introduce datetime.py
1 parent 55f8646 commit 6430ab9

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

Lib/_pydatetime.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,26 +2624,3 @@ def _name_from_offset(delta):
26242624
# small dst() may get within its bounds; and it doesn't even matter if some
26252625
# perverse time zone returns a negative dst()). So a breaking case must be
26262626
# pretty bizarre, and a tzinfo subclass can override fromutc() if it is.
2627-
2628-
try:
2629-
from _datetime import *
2630-
except ImportError:
2631-
pass
2632-
else:
2633-
# Clean up unused names
2634-
del (_DAYNAMES, _DAYS_BEFORE_MONTH, _DAYS_IN_MONTH, _DI100Y, _DI400Y,
2635-
_DI4Y, _EPOCH, _MAXORDINAL, _MONTHNAMES, _build_struct_time,
2636-
_check_date_fields, _check_time_fields,
2637-
_check_tzinfo_arg, _check_tzname, _check_utc_offset, _cmp, _cmperror,
2638-
_date_class, _days_before_month, _days_before_year, _days_in_month,
2639-
_format_time, _format_offset, _index, _is_leap, _isoweek1monday, _math,
2640-
_ord2ymd, _time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord,
2641-
_divide_and_round, _parse_isoformat_date, _parse_isoformat_time,
2642-
_parse_hh_mm_ss_ff, _IsoCalendarDate, _isoweek_to_gregorian,
2643-
_find_isoformat_datetime_separator, _FRACTION_CORRECTION,
2644-
_is_ascii_digit)
2645-
# XXX Since import * above excludes names that start with _,
2646-
# docstring does not get overwritten. In the future, it may be
2647-
# appropriate to maintain a single module level docstring and
2648-
# remove the following line.
2649-
from _datetime import __doc__

Lib/datetime.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
try:
2+
from _datetime import *
3+
from _datetime import __doc__
4+
except ImportError:
5+
from _pydatetime import *
6+
from _pydatetime import __doc__
7+
8+
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
9+
"MINYEAR", "MAXYEAR")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Create a new ``Lib/_pydatetime.py`` file that defines the Python version of
2+
the ``datetime`` module, and make ``datetime`` import the contents of the
3+
new library only if the C implementation is missing. Currently, the full
4+
Python implementation is defined and then deleted if the C implementation is
5+
not available, slowing down ``import datetime`` unnecessarily.

0 commit comments

Comments
 (0)