[Patches] [ python-Patches-483864 ] Pure python version of calendar.weekday
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 07 May 2002 23:14:40 -0700
Patches item #483864, was opened at 2001-11-20 17:42
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=483864&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Hye-Shik Chang (perky)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pure python version of calendar.weekday
Initial Comment:
this version can handle past of 1970, and PURE.
but this is not too slower than old one.
NetBSD machine on Pentium 90MHz:
$ python wday.py 1000
Time Module: 0.641623973846
Pure Python: 0.724056005478
$ python wday.py 10000
Time Module: 6.77021896839
Pure Python: 7.34891104698
Linux machine on Pentium III 800MHz:
$ python wday.py 10000
Time Module: 0.611389994621
Pure Python: 0.833150982857
$ python wday.py 100000
Time Module: 6.12289500237
Pure Python: 8.36460494995
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-05-08 06:14
Message:
Logged In: YES
user_id=80475
Thanks for the patch. Here are a few suggestions:
- Use diff -c for your patch
- Update the patch to diff from the current version, 1.27.
- Also change the library reference which specifies 1970.
- Expand test_calendar.py to include your expanded range.
- Add a range check to weekday() to raise an Error if date
is before 1752 (this will be a common error if the century
is omitted in a call). The current treat is to raise
ValueError: year out of range.
- Eliminate the comment # Importing add from operator
- Change the multi-line style away from using \ which
relies on there being no extra spaces at the end of a
line. Instead write:
sum = a +
b -
c
- Revise the doc string to specify "Accurate for date from
September 14, 1752". As specified now, it implies accuracy
to the beginning of that year.
- Create a special case for monthcalendar() to handle
September 1752
- Submit a separate Python program that runs every possible
monthcalendar from 1752 and compares the result to the Unix
cal program. I checked your logic and it looks fine, but a
comprehensive compare will be doubly persuasive. Some
similar proof of daygap() would be helpful.
- Either add daygap() to the docs or incorporate it
directly inside weekday().
----------------------------------------------------------------------
Comment By: Hye-Shik Chang (perky)
Date: 2001-11-20 17:51
Message:
Logged In: YES
user_id=55188
upper one of two patches is using if - if.
another is using and - or.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=483864&group_id=5470