gweis / isodate

ISO 8601 date/time parser
BSD 3-Clause "New" or "Revised" License
155 stars 59 forks source link

parse_datetime() is slow #9

Closed roysmith closed 7 years ago

roysmith commented 10 years ago

Surprisingly, isodate.parse_datetime() is significantly slower than the more general-purpose dateutil.parser.parse().

$ python -m timeit -s "from dateutil.parser import parse" "parse('2014-04-01T11:46')" 10000 loops, best of 3: 106 usec per loop $ python -m timeit -s "from isodate import parse_datetime as parse" "parse('2014-04-01T11:46')" 10000 loops, best of 3: 147 usec per loop

gweis commented 10 years ago

Hi thanks, for bringing this to my attention,

Ran the tests as well and got the following results:

python 3.3.4:

$ python -m timeit -s "from dateutil.parser import parse" "parse('2014-04-01T11:46')" 10000 loops, best of 3: 49.7 usec per loop $ python -m timeit -s "from isodate import parse_datetime as parse" "parse('2014-04-01T11:46')" 100000 loops, best of 3: 18.2 usec per loop

python 2.7.6:

$ python -m timeit -s "from dateutil.parser import parse" "parse('2014-04-01T11:46')" 10000 loops, best of 3: 65.2 usec per loop $ python -m timeit -s "from isodate import parse_datetime as parse" "parse('2014-04-01T11:46')" 10000 loops, best of 3: 64.7 usec per loop

interesting that python 3 is a lot faster than python 2 might be worth investigating why there is almost no difference in python2.

cheers,

Gerhard

On 3 Apr 2014, at 13:57, Roy Smith notifications@github.com wrote:

Surprisingly, isodate.parse_datetime() is significantly slower than the more general-purpose dateutil.parser.parse().

$ python -m timeit -s "from dateutil.parser import parse" "parse('2014-04-01T11:46')" 10000 loops, best of 3: 106 usec per loop $ python -m timeit -s "from isodate import parse_datetime as parse" "parse('2014-04-01T11:46')" 10000 loops, best of 3: 147 usec per loop

— Reply to this email directly or view it on GitHub.