[Datetime-SIG] strategy for the C part of ISO 8601 datetime parsing

Mathieu Dupuy deronnax at gmail.com
Wed May 31 15:27:28 EDT 2017


Hi datetime mates

I would like to resume soon the C implementation of datetime iso
format parsing in CPython I started days ago
(http://bugs.python.org/issue15873). Currently I have 2 solutions and
would like to know which one do you prefer:

* iterating on the string the string, stopping when something is wrong
(might process almost all of the string and finally give up because
last part is wrong, EG incorrect microseconds or time zone. Penalize
invalid strings, best case when most of the strings to process are
valid)
* first checking the string is correct, then iterating over it and
handling each part. Early detection of incorrect strings, useless
overhead for valid string. Penalize valid strings, best case when most
of the strings to process are invalid).

I have a preference for solution #1. I first thought of using sscanf
but it's impossible for many reasons, the first of them is scanf is
unsuitable for variable numbers of match (you can't express optional
match in scanf format).

Waiting for your input.


More information about the Datetime-SIG mailing list