[issue12886] datetime.strptime parses input wrong
Heiðar Rafn Harðarson heidar.r...@hrolfsskali.net added the comment: My understanding of the python documentation and the ISO 8601 standard is that the digits in a timestamp representing hours, minutes and seconds shall always be in pairs of 2 digits (hh, mm, ss), i.e. when a number is less than 10 it should be preceded by 0. In the example I give, the minute figure is split between minutes and seconds by the python library function which I consider a bug: datetime.datetime.strptime('20110817T1234','%Y%m%dT%H%M%S') gives datetime.datetime(2011, 8, 17, 12, 3, 4) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12886 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12886] datetime.strptime parses input wrong
Heiðar Rafn Harðarson heidar.r...@hrolfsskali.net added the comment: This issue is also discussed here: http://bugs.python.org/issue5979 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12886 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12886] datetime.strptime parses input wrong
New submission from Heiðar Rafn Harðarson heidar.r...@hrolfsskali.net: When using datetime.strptime or time.strptime to parse string representing timestamp with the format string '%Y%m%dT%H%M%S' then a strange behavior happens when the input string does not contain the seconds: the minute part is split and first digit used as minutes and second digit as seconds ! According to documentation %M shall contain Minute as a decimal number [00,59] and %S shall contain Second as a decimal number [00,61] Here are few examples to show this: -- Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type help, copyright, credits or license for more information. import datetime datetime.datetime.strptime('20110817T1234','%Y%m%dT%H%M%S') datetime.datetime(2011, 8, 17, 12, 3, 4) =ERROR no seconds in input string: minute=3, second=4 =I would expect exception ValueError or datetime.datetime(2011, 8, 17, 12, 34, 00) datetime.datetime.strptime('20110817T123456','%Y%m%dT%H%M%S') datetime.datetime(2011, 8, 17, 12, 34, 56) =CORRECT datetime.datetime.strptime('20110817T123456','%Y%m%dT%H%M') Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.6/_strptime.py, line 328, in _strptime data_string[found.end():]) ValueError: unconverted data remains: 56 =CORRECT datetime.datetime.strptime('20110817T1234','%Y%m%dT%H%M') datetime.datetime(2011, 8, 17, 12, 34) = CORRECT -- I have tested this with python 2.6 and 2.7 This also happens on when playing with %H%M format string and omit minutes from the input. -- components: Library (Lib) messages: 143400 nosy: heidar.rafn priority: normal severity: normal status: open title: datetime.strptime parses input wrong type: behavior versions: Python 2.6, Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12886 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6931] awful performance in difflib: ndiff and HtmlDiff
New submission from Heiðar Rafn Harðarson heidar.r...@hrolfsskali.net: Relatively small set of lines with differences in most lines can destroy the performance of difflib.HtmlDiff.make_table and difflib.ndiff. I am using it like this: ... htmldiffer = HtmlDiff() return htmldiffer.make_table(src_lines, dst_lines, fromdesc=file1, todesc=file2, context=True) I have written the src_lines and dst_lins to files and tried this with the Tools/scripts/diff.py wrapper with same results when using the switches -m or -n. The performance is fine when using difflib.unified_diff or switch -u on diff.py Attached are files that show this clearly. left200.txt,right200.txt - 200 lines of text - duration 11 seconds. left500.txt,right500.txt - 500 lines of text - duration 2min 58 sec left1000.txt,right1000.txt - 1000 lines of text - duration 29min 4sec tested on Intel dualcore T2500 2GHz with 2 GB of memory, python 2.5.2 on Ubuntu. Same problom on python 2.6 on Fedora-11 For reference, the kdiff3 utility performs beautifully on these files. -- components: Library (Lib) files: python.difflib.bug.tgz messages: 92768 nosy: heidar.rafn severity: normal status: open title: awful performance in difflib: ndiff and HtmlDiff type: performance versions: Python 2.5, Python 2.6 Added file: http://bugs.python.org/file14911/python.difflib.bug.tgz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6931 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6931] dreadful performance in difflib: ndiff and HtmlDiff
Changes by Heiðar Rafn Harðarson heidar.r...@hrolfsskali.net: -- title: awful performance in difflib: ndiff and HtmlDiff - dreadful performance in difflib: ndiff and HtmlDiff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6931 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com