diff --git a/README.rst b/README.rst index bc7454c..0278ed2 100644 --- a/README.rst +++ b/README.rst @@ -81,45 +81,45 @@ Parsing a timestamp with no time zone information (e.g., ``2014-01-09T21:48:00`` .. table:: - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - | Module |Python 3.12|Python 3.11|Python 3.10|Python 3.9|Relative slowdown (versus ciso8601, latest Python)|…|Python 3.8|Python 3.7| Python 2.7 | - +================================+===========+===========+===========+==========+==================================================+=+==========+==========+===============================+ - |ciso8601 |98 nsec |90 nsec |122 nsec |122 nsec |N/A |…|118 nsec |124 nsec |134 nsec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |backports.datetime_fromisoformat|N/A |N/A |112 nsec |108 nsec |0.9x |…|106 nsec |118 nsec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |datetime (builtin) |129 nsec |132 nsec |N/A |N/A |1.3x |…|N/A |N/A |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |pendulum |N/A |180 nsec |187 nsec |186 nsec |2.0x |…|196 nsec |200 nsec |8.52 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |udatetime |695 nsec |662 nsec |674 nsec |692 nsec |7.1x |…|724 nsec |713 nsec |586 nsec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |str2date |6.86 usec |5.78 usec |6.59 usec |6.4 usec |70.0x |…|6.66 usec |6.96 usec |❌ | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |iso8601utils |N/A |N/A |N/A |8.59 usec |70.5x |…|8.6 usec |9.59 usec |11.2 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |iso8601 |10 usec |8.24 usec |8.96 usec |9.21 usec |102.2x |…|9.14 usec |9.63 usec |25.7 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |isodate |11.1 usec |8.76 usec |10.2 usec |9.76 usec |113.6x |…|9.92 usec |11 usec |44.1 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |PySO8601 |17.2 usec |13.6 usec |16 usec |15.8 usec |175.3x |…|16.1 usec |17.1 usec |17.7 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |aniso8601 |22.2 usec |17.8 usec |23.2 usec |23.1 usec |227.0x |…|24.3 usec |27.2 usec |30.7 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |zulu |23.3 usec |19 usec |22 usec |21.3 usec |237.9x |…|21.6 usec |22.7 usec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |maya |N/A |36.1 usec |42.5 usec |42.7 usec |401.6x |…|41.3 usec |44.2 usec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |python-dateutil |57.6 usec |51.4 usec |63.3 usec |62.6 usec |587.7x |…|63.7 usec |67.3 usec |119 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |arrow |62 usec |54 usec |65.5 usec |65.7 usec |633.0x |…|66.6 usec |70.2 usec |78.8 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |metomi-isodatetime |1.29 msec |1.33 msec |1.76 msec |1.77 msec |13201.1x |…|1.79 msec |1.91 msec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |moment |1.81 msec |1.65 msec |1.75 msec |1.79 msec |18474.8x |…|1.78 msec |1.84 msec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - -ciso8601 takes 98 nsec, which is **1.3x faster than datetime (builtin)**, the next fastest Python 3.12 parser in this comparison. + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + | Module |Python 3.13|Python 3.12|Python 3.11|Python 3.10|Relative slowdown (versus ciso8601, latest Python)|…|Python 3.9|Python 3.8| + +================================+===========+===========+===========+===========+==================================================+=+==========+==========+ + |ciso8601 |64.8 nsec |62.8 nsec |60.1 nsec |91.7 nsec |N/A |…|86 nsec |92.9 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |backports.datetime_fromisoformat|N/A |N/A |N/A |73.6 nsec |0.8x |…|70 nsec |75.9 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |datetime (builtin) |147 nsec |138 nsec |123 nsec |N/A |2.3x |…|N/A |N/A | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |pendulum |171 nsec |181 nsec |175 nsec |214 nsec |2.6x |…|179 nsec |180 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |udatetime |542 nsec |563 nsec |525 nsec |555 nsec |8.4x |…|551 nsec |553 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |str2date |3.29 usec |3.53 usec |3.52 usec |3.85 usec |50.8x |…|3.72 usec |3.9 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |iso8601utils |N/A |N/A |N/A |N/A |56.9x |…|4.89 usec |4.89 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |iso8601 |5.1 usec |5.4 usec |5.18 usec |5.38 usec |78.8x |…|5.36 usec |5.55 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |isodate |5.76 usec |5.85 usec |5.21 usec |5.91 usec |89.0x |…|5.97 usec |6.07 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |PySO8601 |10 usec |11.5 usec |7.99 usec |10.9 usec |155.0x |…|9.83 usec |9.81 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |aniso8601 |12.1 usec |12.5 usec |11.1 usec |15.1 usec |186.9x |…|15.4 usec |15.6 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |zulu |12.3 usec |13.6 usec |12.6 usec |14.2 usec |189.4x |…|14.5 usec |14.2 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |maya |35.9 usec |N/A |40.6 usec |46.7 usec |554.3x |…|45.4 usec |46.3 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |python-dateutil |36.2 usec |36.9 usec |36.1 usec |44 usec |558.5x |…|46.4 usec |45.2 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |arrow |42.9 usec |43.8 usec |41.2 usec |48.8 usec |662.7x |…|50.7 usec |50.1 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |metomi-isodatetime |828 usec |822 usec |791 usec |1.09 msec |12781.0x |…|1.1 msec |1.11 msec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |moment |1.28 msec |1.32 msec |1.29 msec |1.36 msec |19696.9x |…|1.37 msec |1.34 msec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + +ciso8601 takes 64.8 nsec, which is **2.3x faster than datetime (builtin)**, the next fastest Python 3.13 parser in this comparison. .. @@ -129,70 +129,70 @@ Parsing a timestamp with time zone information (e.g., ``2014-01-09T21:48:00-05:3 .. table:: - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - | Module |Python 3.12|Python 3.11|Python 3.10|Python 3.9|Relative slowdown (versus ciso8601, latest Python)|…|Python 3.8|Python 3.7| Python 2.7 | - +================================+===========+===========+===========+==========+==================================================+=+==========+==========+===============================+ - |ciso8601 |95 nsec |96.8 nsec |128 nsec |123 nsec |N/A |…|125 nsec |125 nsec |140 nsec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |backports.datetime_fromisoformat|N/A |N/A |147 nsec |149 nsec |1.1x |…|138 nsec |149 nsec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |datetime (builtin) |198 nsec |207 nsec |N/A |N/A |2.1x |…|N/A |N/A |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |pendulum |N/A |225 nsec |214 nsec |211 nsec |2.3x |…|219 nsec |224 nsec |13.5 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |udatetime |799 nsec |803 nsec |805 nsec |830 nsec |8.4x |…|827 nsec |805 nsec |768 nsec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |str2date |7.73 usec |6.75 usec |7.78 usec |7.8 usec |81.4x |…|7.74 usec |8.13 usec |❌ | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |iso8601 |13.7 usec |11.3 usec |12.7 usec |12.5 usec |143.8x |…|12.4 usec |12.6 usec |31.1 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |isodate |13.7 usec |11.3 usec |12.9 usec |12.7 usec |144.0x |…|12.7 usec |13.9 usec |46.7 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |iso8601utils |N/A |N/A |N/A |21.4 usec |174.9x |…|22.1 usec |23.4 usec |28.3 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |PySO8601 |25.1 usec |20.4 usec |23.2 usec |23.8 usec |263.8x |…|23.5 usec |24.8 usec |25.3 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |zulu |26.3 usec |21.4 usec |25.7 usec |24 usec |277.2x |…|24.5 usec |25.3 usec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |aniso8601 |27.7 usec |23.7 usec |30.3 usec |30 usec |291.3x |…|31.6 usec |33.8 usec |39.2 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |maya |N/A |36 usec |41.3 usec |41.8 usec |372.0x |…|42.4 usec |42.7 usec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |python-dateutil |70.7 usec |65.1 usec |77.9 usec |80.2 usec |744.0x |…|79.4 usec |83.6 usec |100 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |arrow |73 usec |62.8 usec |74.5 usec |73.9 usec |768.6x |…|75.1 usec |80 usec |148 usec | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |metomi-isodatetime |1.22 msec |1.25 msec |1.72 msec |1.72 msec |12876.3x |…|1.76 msec |1.83 msec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - |moment |❌ |❌ |❌ |❌ |2305822.8x |…|❌ |❌ |N/A | - +--------------------------------+-----------+-----------+-----------+----------+--------------------------------------------------+-+----------+----------+-------------------------------+ - -ciso8601 takes 95 nsec, which is **2.1x faster than datetime (builtin)**, the next fastest Python 3.12 parser in this comparison. + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + | Module |Python 3.13|Python 3.12|Python 3.11|Python 3.10|Relative slowdown (versus ciso8601, latest Python)|…|Python 3.9|Python 3.8| + +================================+===========+===========+===========+===========+==================================================+=+==========+==========+ + |ciso8601 |73.9 nsec |71 nsec |65.6 nsec |97.5 nsec |N/A |…|92.9 nsec |96.6 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |backports.datetime_fromisoformat|N/A |N/A |N/A |99.2 nsec |1.0x |…|93 nsec |99.4 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |datetime (builtin) |205 nsec |198 nsec |178 nsec |N/A |2.8x |…|N/A |N/A | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |pendulum |251 nsec |259 nsec |251 nsec |262 nsec |3.4x |…|264 nsec |264 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |udatetime |684 nsec |700 nsec |646 nsec |684 nsec |9.3x |…|688 nsec |676 nsec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |str2date |5.95 usec |4.34 usec |4.11 usec |4.58 usec |80.5x |…|4.6 usec |4.82 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |iso8601 |7.68 usec |8.56 usec |7.62 usec |7.99 usec |103.9x |…|7.83 usec |8.16 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |isodate |7.77 usec |8.53 usec |7.54 usec |7.88 usec |105.0x |…|8.12 usec |8.4 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |iso8601utils |N/A |N/A |N/A |N/A |152.2x |…|14.1 usec |14.6 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |zulu |17.8 usec |16.9 usec |15.7 usec |17.3 usec |241.3x |…|17.3 usec |17.6 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |aniso8601 |18 usec |18.7 usec |16.4 usec |21.5 usec |243.1x |…|22.5 usec |22.8 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |PySO8601 |18.3 usec |16.6 usec |14.3 usec |15.8 usec |247.5x |…|16.2 usec |16.4 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |maya |46.2 usec |N/A |41 usec |47.5 usec |625.0x |…|45.2 usec |47 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |python-dateutil |47.1 usec |48.2 usec |47.1 usec |57.3 usec |636.5x |…|60.4 usec |58.9 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |arrow |57.7 usec |53.8 usec |50.8 usec |60.2 usec |780.2x |…|59.4 usec |60.1 usec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |metomi-isodatetime |876 usec |823 usec |795 usec |1.09 msec |11846.4x |…|1.09 msec |1.13 msec | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + |moment |❌ |❌ |❌ |❌ |2070678.8x |…|❌ |❌ | + +--------------------------------+-----------+-----------+-----------+-----------+--------------------------------------------------+-+----------+----------+ + +ciso8601 takes 73.9 nsec, which is **2.8x faster than datetime (builtin)**, the next fastest Python 3.13 parser in this comparison. .. .. -Tested on Linux 5.15.49-linuxkit using the following modules: +Tested on Linux 6.11.5-orbstack-00280-g96d99c92a42b using the following modules: .. code:: python aniso8601==9.0.1 - arrow==1.3.0 (on Python 3.8, 3.9, 3.10, 3.11, 3.12), arrow==1.2.3 (on Python 3.7), arrow==0.17.0 (on Python 2.7) - backports.datetime_fromisoformat==2.0.1 - ciso8601==2.3.0 - iso8601==2.1.0 (on Python 3.8, 3.9, 3.10, 3.11, 3.12), iso8601==0.1.16 (on Python 2.7) + arrow==1.3.0 + backports.datetime_fromisoformat==2.0.2 + ciso8601==2.3.1 + iso8601==2.1.0 iso8601utils==0.1.2 - isodate==0.6.1 + isodate==0.7.2 maya==0.6.1 metomi-isodatetime==1!3.1.0 moment==0.12.1 - pendulum==2.1.2 + pendulum==3.0.0 PySO8601==0.2.0 - python-dateutil==2.8.2 + python-dateutil==2.9.0.post0 str2date==0.905 udatetime==0.0.17 - zulu==2.0.0 + zulu==2.0.1 .. diff --git a/benchmarking/Dockerfile b/benchmarking/Dockerfile index 21179f8..e3a8312 100644 --- a/benchmarking/Dockerfile +++ b/benchmarking/Dockerfile @@ -8,6 +8,9 @@ RUN apt-get update && \ # Install the other dependencies RUN apt-get install -y git curl gcc build-essential +# Install the Rust toolchain for `pendulum` +RUN curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- -y + # Install tzdata non-iteractively # https://stackoverflow.com/questions/44331836/apt-get-install-tzdata-noninteractive/44333806#44333806 RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata diff --git a/benchmarking/perform_comparison.py b/benchmarking/perform_comparison.py index d4b9ede..ca3f7cd 100644 --- a/benchmarking/perform_comparison.py +++ b/benchmarking/perform_comparison.py @@ -23,6 +23,7 @@ "python-dateutil": ("import dateutil.parser", "dateutil.parser.parse('{timestamp}')"), "iso8601": ("import iso8601", "iso8601.parse_date('{timestamp}')"), "isodate": ("import isodate", "isodate.parse_datetime('{timestamp}')"), + "pendulum": ("from pendulum.parsing import parse_iso8601", "parse_iso8601('{timestamp}')"), "PySO8601": ("import PySO8601", "PySO8601.parse('{timestamp}')"), "str2date": ("from str2date import str2date", "str2date('{timestamp}')"), } @@ -59,15 +60,10 @@ # `arrow` no longer supports Python 3.4 ISO_8601_MODULES["arrow"] = ("import arrow", "arrow.get('{timestamp}').datetime") -if sys.version_info.major >= 3 and (sys.version_info.major, sys.version_info.minor) < (3, 12): +if sys.version_info.major >= 3: # `maya` uses a version of `regex` which no longer supports Python 2 - # `maya` uses `pendulum`, which doesn't yet support Python 3.12 ISO_8601_MODULES["maya"] = ("import maya", "maya.parse('{timestamp}').datetime()") -if (sys.version_info.major, sys.version_info.minor) < (3, 12): - # `pendulum` doesn't yet support Python 3.12 - ISO_8601_MODULES["pendulum"] = ("from pendulum.parsing import parse_iso8601", "parse_iso8601('{timestamp}')") - if (sys.version_info.major, sys.version_info.minor) >= (3, 5): # `moment` is built on `times`, which is built on `arrow`, which no longer supports Python 3.4 # `moment` uses a version of `regex` which no longer supports Python 2 diff --git a/benchmarking/tox.ini b/benchmarking/tox.ini index e54854a..c6bec66 100644 --- a/benchmarking/tox.ini +++ b/benchmarking/tox.ini @@ -1,7 +1,7 @@ [tox] requires = tox>=4 -envlist = py313,py312,py311,py310,py39,py38,py37 +envlist = py313,py312,py311,py310,py39,py38 setupdir=.. [testenv] @@ -26,14 +26,12 @@ deps= iso8601utils; python_version != '3.6' and python_version != '3.10' isodate ; `maya` uses a version of `regex` which no longer supports Python 2 - ; `maya` uses `pendulum`, which doesn't yet support Python 3.12 - maya; python_version > '3' and python_version < '3.12' + maya; python_version > '3' metomi-isodatetime; python_version >= '3.5' ; `moment` is built on `times`, which is built on `arrow`, which no longer supports Python 3.4 ; `moment` uses a version of `regex` which no longer supports Python 2 moment; python_version >= '3.5' - ; `pendulum` doesn't yet support Python 3.12 - pendulum; python_version < '3.12' + pendulum pyso8601 python-dateutil str2date