Skip to content

Commit

Permalink
Avoid storing _aday, _fday and _pday in memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 8, 2011
1 parent e62496e commit ace0f98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
3.0 (unreleased)
----------------

- Avoid storing `_aday`, `_fday` and `_pday` in memory.

- Moved various internal parsing related class variables to module constants.

- No longer provide the `DateError`, `DateTimeError`, `SyntaxError` and
Expand Down
19 changes: 13 additions & 6 deletions src/DateTime/DateTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,6 @@ class DateTime(object):
'_fmon',
'_amon',
'_pmon',
'_fday',
'_aday',
'_pday',
'_year',
'_month',
'_day',
Expand Down Expand Up @@ -837,11 +834,9 @@ def _parse_args(self, *args, **kw):
else:
self._pmhour=hr or 12
self._pm= (hr==12) and 'pm' or 'am'
self._dayoffset=dx=int((_julianday(yr,mo,dy)+2L)%7)
self._dayoffset = int((_julianday(yr,mo,dy) + 2L) % 7)
self._fmon, self._amon, self._pmon = \
_MONTHS[mo], _MONTHS_A[mo], _MONTHS_P[mo]
self._fday,self._aday,self._pday= \
_DAYS[dx], _DAYS_A[dx], _DAYS_P[dx]
# Round to nearest microsecond in platform-independent way. You
# cannot rely on C sprintf (Python '%') formatting to round
# consistently; doing it ourselves ensures that all but truly
Expand Down Expand Up @@ -1384,6 +1379,10 @@ def day(self):
"""Return the integer day."""
return self._day

@property
def _fday(self):
return _DAYS[self._dayoffset]

def Day(self):
"""Return the full name of the day of the week."""
return self._fday
Expand All @@ -1392,10 +1391,18 @@ def DayOfWeek(self):
"""Compatibility: see Day."""
return self._fday

@property
def _aday(self):
return _DAYS_A[self._dayoffset]

def aDay(self):
"""Return the abreviated name of the day of the week."""
return self._aday

@property
def _pday(self):
return _DAYS_P[self._dayoffset]

def pDay(self):
"""Return the abreviated (with period) name of the day of the week."""
return self._pday
Expand Down

0 comments on commit ace0f98

Please sign in to comment.