Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22462

Simon: ciso8601 vs mxDateTime vs udatetime

$
0
0

In my last performance comparison I compared libraries with non performance goals with datetime and udatetime, to illustrate the impact of your library choice. Arrow, Pendulum and Delorean are awesome choices when it comes to ease of use, but not if you need performance. Of course comparing libraries with different goals in mind isn’t really fair so I decided to compare libraries with the same design goals.

This benchmark compares ciso8601 and mxDateTime with udatetime. ciso8601 is implemented in C, supports Python 2.7, Python 3.5 and PyPy, but is for parsing only. mxDateTime is also implemented in C, but supports only Python 2.7.

The benchmark to compare Python datetime, udatetime, ciso8601 and mxDateTime can be found here. I again picked 4 typical performance critical operations to measure the speed of those libraries.

  • Decode a date-time string
  • Encode (serialize) a date-time string
  • Instantiate object with current time in UTC
  • Instantiate object with current time in local timezone
  • Instantiate object from timestamp in UTC
  • Instantiate object from timestamp in local timezone

The benchmark was done for Python 2.7, PyPy and Python 3.5. As usual 1 million executions per benchmark and picked the min of 3 repeats.

Benchmark result for benchmark_parse

Although ciso8601 is optimized to parse ISO8601 date-times, it’s still 2 times slower than udatetime. mxDateTime is 3.5 times slower in parsing than udatetime.

Over all mxDateTime is 5 times slower than udatetime. ciso8601 can’t be compared on that level, because it only supports parsing and none of the other benchmarks.

On Python 3.5 ciso8601 is 3 times slower and on PyPy 5 times slower than udatetime. mxDateTime can’t be compared to ciso8601 and udatetime on Python 3.5 and PyPy, because it only supports Python 2.7.

Benchmark result details for Python 2.7

mxDateTime’s performance isn’t bad for a library which could completely replace Python datetime, but I wouldn’t recommend using it. Although it’s tagged ‘Development Status :: 6 - Mature’ it still has issues with basics.

>>>importmx.DateTimeasDateTime>>>frommx.DateTimeimportISO>>>mx=ISO.ParseDateTime('2016-07-18T12:58:26.485897-02:00')>>>ISO.str(mx)'2016-07-18 12:58:26+0200'

Notice the timezone changed from -02:00 to +02:00.


Viewing all articles
Browse latest Browse all 22462

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>