Size: 302
Comment:
|
Size: 2311
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
Python 2.3 introduced a new module datetime. * http://online.effbot.org/2003_08_01_archive.htm#librarybook-datetime-module * http://docs.python.org/lib/module-datetime.html |
|
Line 5: | Line 8: |
Since these modules are implemented in C, it would be nice to have a Java implementation for Jython. A pure python implementation of datetime can be find at http://cvs.sf.net/viewcvs.py/python/python/nondist/sandbox/datetime/ . I plan on using this implementation extensively as the Java version is developed. If it turns out that a Java implementation is infeasible or will take too long, we could always fall back on using this module directly. My original plan was to write the entire module in Java, using mxDateTime for guidance http://cvs.sourceforge.net/viewcvs.py/zxpy/zxDateTime/ . However, after reading this addition to JythonModulesInJava by BrianZimmer: |
|
Line 7: | Line 13: |
>>> import datetime | My new approach is borrowed slightly from CPython where it's very common to write a C library, a straight wrapper and then a Pythonic wrapper. In Jython, the first two steps are really one so the development effort is significantly simplified. Writing a wrapper in Python offers the dual benefits of being easy to maintain and refactor as well as requiring less development time. |
Line 10: | Line 21: |
I've re-thought that approach, and I now plan to start with the pure python datetime and replace the date related code with java.util.Calendar code. | |
Line 14: | Line 25: |
||timexxx|||| ||timedelta|||| ||date|||| ||tzinfo|||| ||time|||| ||datetime|||| |
||timexxx||I think this is just a placeholder for something in C...|| ||timedelta||For now I plan to leave this alone, though this may be a place where a Java reimplementation may give a performance boost.|| ||date||Replace most logic with java.util.Catalog code.|| ||tzinfo||This needs more study, but I may be able to replace some logic with TimeZone from Java|| ||time||Leave as is for now, but review later|| ||datetime||Replace most logic with java.util.Catalog code.|| |
Line 23: | Line 34: |
For the short term I plan to use the Python unittests as the definition of the datetime class, and will not try to go beyond the CPython implementation. This may change once Jython starts to catch up with the leading edge of CPython development. |
FrankWierzbicki is leading the implementation of the datetime module.
Background
Python 2.3 introduced a new module datetime.
Since these modules are implemented in C, it would be nice to have a Java implementation for Jython. A pure python implementation of datetime can be find at http://cvs.sf.net/viewcvs.py/python/python/nondist/sandbox/datetime/ . I plan on using this implementation extensively as the Java version is developed. If it turns out that a Java implementation is infeasible or will take too long, we could always fall back on using this module directly.
My original plan was to write the entire module in Java, using mxDateTime for guidance http://cvs.sourceforge.net/viewcvs.py/zxpy/zxDateTime/ . However, after reading this addition to JythonModulesInJava by BrianZimmer:
My new approach is borrowed slightly from CPython where it's very common to write a C library, a straight wrapper and then a Pythonic wrapper. In Jython, the first two steps are really one so the development effort is significantly simplified. Writing a wrapper in Python offers the dual benefits of being easy to maintain and refactor as well as requiring less development time.
I've re-thought that approach, and I now plan to start with the pure python datetime and replace the date related code with java.util.Calendar code.
Design
Jython Class |
Strategy |
timexxx |
I think this is just a placeholder for something in C... |
timedelta |
For now I plan to leave this alone, though this may be a place where a Java reimplementation may give a performance boost. |
date |
Replace most logic with java.util.Catalog code. |
tzinfo |
This needs more study, but I may be able to replace some logic with TimeZone from Java |
time |
Leave as is for now, but review later |
datetime |
Replace most logic with java.util.Catalog code. |
Discussion
For the short term I plan to use the Python unittests as the definition of the datetime class, and will not try to go beyond the CPython implementation. This may change once Jython starts to catch up with the leading edge of CPython development.