diff --git a/README.rst b/README.rst index 8173e67..c72943d 100644 --- a/README.rst +++ b/README.rst @@ -81,43 +81,43 @@ 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|Python 3.8|Python 3.7| Python 2.7 |Relative slowdown (versus ciso8601, latest Python)| - +================================+===========+===========+===========+==========+==========+==========+===============================+==================================================+ - |ciso8601 |94.4 nsec |89.2 nsec |125 nsec |117 nsec |129 nsec |122 nsec |134 nsec |N/A | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |backports.datetime_fromisoformat|N/A |N/A |112 nsec |105 nsec |106 nsec |112 nsec |N/A |0.9x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |datetime (builtin) |129 nsec |136 nsec |N/A |N/A |N/A |N/A |N/A |1.4x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |pendulum |N/A |184 nsec |191 nsec |191 nsec |192 nsec |204 nsec |8.52 usec |2.1x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |udatetime |709 nsec |677 nsec |692 nsec |715 nsec |705 nsec |700 nsec |586 nsec |7.5x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |str2date |6.84 usec |5.8 usec |6.86 usec |6.6 usec |6.47 usec |6.89 usec |**Incorrect Result** (``None``)|72.5x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |iso8601utils |N/A |N/A |N/A |8.64 usec |8.69 usec |9.2 usec |11.2 usec |74.0x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |iso8601 |9.41 usec |8.06 usec |9.2 usec |9.05 usec |9.35 usec |9.38 usec |25.7 usec |99.6x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |isodate |10.5 usec |8.68 usec |10.2 usec |9.68 usec |10.1 usec |10.9 usec |44.1 usec |111.4x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |PySO8601 |17.1 usec |13.4 usec |16.4 usec |16.1 usec |16.6 usec |17.1 usec |17.7 usec |181.2x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |aniso8601 |21.7 usec |18.1 usec |24 usec |23.3 usec |23.7 usec |27.6 usec |30.7 usec |229.6x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |zulu |23.5 usec |20.1 usec |22.4 usec |21.3 usec |21.8 usec |22.2 usec |N/A |248.7x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |maya |N/A |37.4 usec |42.4 usec |42.1 usec |42.2 usec |43 usec |N/A |419.4x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |python-dateutil |55.5 usec |51.6 usec |63 usec |62.9 usec |65.4 usec |67.8 usec |119 usec |588.0x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |arrow |62.7 usec |54.4 usec |65.5 usec |64.6 usec |65 usec |71.2 usec |78.8 usec |664.2x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |metomi-isodatetime |1.31 msec |1.3 msec |1.76 msec |1.78 msec |1.78 msec |1.91 msec |N/A |13823.8x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ - |moment |1.79 msec |1.73 msec |1.77 msec |1.75 msec |1.79 msec |1.95 msec |N/A |18962.8x | - +--------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+--------------------------------------------------+ + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + | Module |Relative slowdown (versus ciso8601, latest Python)|Python 3.12|Python 3.11|Python 3.10|Python 3.9|Python 3.8|Python 3.7| Python 2.7 | + +================================+==================================================+===========+===========+===========+==========+==========+==========+===============================+ + |ciso8601 |N/A |94.4 nsec |89.2 nsec |125 nsec |117 nsec |129 nsec |122 nsec |134 nsec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |backports.datetime_fromisoformat|0.9x |N/A |N/A |112 nsec |105 nsec |106 nsec |112 nsec |N/A | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |datetime (builtin) |1.4x |129 nsec |136 nsec |N/A |N/A |N/A |N/A |N/A | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |pendulum |2.1x |N/A |184 nsec |191 nsec |191 nsec |192 nsec |204 nsec |8.52 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |udatetime |7.5x |709 nsec |677 nsec |692 nsec |715 nsec |705 nsec |700 nsec |586 nsec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |str2date |72.5x |6.84 usec |5.8 usec |6.86 usec |6.6 usec |6.47 usec |6.89 usec |**Incorrect Result** (``None``)| + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |iso8601utils |74.0x |N/A |N/A |N/A |8.64 usec |8.69 usec |9.2 usec |11.2 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |iso8601 |99.6x |9.41 usec |8.06 usec |9.2 usec |9.05 usec |9.35 usec |9.38 usec |25.7 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |isodate |111.4x |10.5 usec |8.68 usec |10.2 usec |9.68 usec |10.1 usec |10.9 usec |44.1 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |PySO8601 |181.2x |17.1 usec |13.4 usec |16.4 usec |16.1 usec |16.6 usec |17.1 usec |17.7 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |aniso8601 |229.6x |21.7 usec |18.1 usec |24 usec |23.3 usec |23.7 usec |27.6 usec |30.7 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |zulu |248.7x |23.5 usec |20.1 usec |22.4 usec |21.3 usec |21.8 usec |22.2 usec |N/A | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |maya |419.4x |N/A |37.4 usec |42.4 usec |42.1 usec |42.2 usec |43 usec |N/A | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |python-dateutil |588.0x |55.5 usec |51.6 usec |63 usec |62.9 usec |65.4 usec |67.8 usec |119 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |arrow |664.2x |62.7 usec |54.4 usec |65.5 usec |64.6 usec |65 usec |71.2 usec |78.8 usec | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |metomi-isodatetime |13823.8x |1.31 msec |1.3 msec |1.76 msec |1.78 msec |1.78 msec |1.91 msec |N/A | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ + |moment |18962.8x |1.79 msec |1.73 msec |1.77 msec |1.75 msec |1.79 msec |1.95 msec |N/A | + +--------------------------------+--------------------------------------------------+-----------+-----------+-----------+----------+----------+----------+-------------------------------+ ciso8601 takes 94.4 nsec, which is **1.4x faster than datetime (builtin)**, the next fastest Python 3.12 parser in this comparison. @@ -129,43 +129,43 @@ 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 | Python 3.8 | Python 3.7 | Python 2.7 |Relative slowdown (versus ciso8601, latest Python)| - +================================+===============================+===============================+===============================+===============================+===============================+===============================+===============================+==================================================+ - |ciso8601 |106 nsec |97 nsec |129 nsec |125 nsec |118 nsec |132 nsec |140 nsec |N/A | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |backports.datetime_fromisoformat|N/A |N/A |148 nsec |142 nsec |139 nsec |148 nsec |N/A |1.1x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |datetime (builtin) |197 nsec |203 nsec |N/A |N/A |N/A |N/A |N/A |1.9x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |pendulum |N/A |210 nsec |214 nsec |209 nsec |216 nsec |225 nsec |13.5 usec |2.2x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |udatetime |828 nsec |785 nsec |805 nsec |811 nsec |798 nsec |816 nsec |768 nsec |7.8x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |str2date |7.79 usec |6.86 usec |7.71 usec |7.77 usec |7.62 usec |8 usec |**Incorrect Result** (``None``)|73.6x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |iso8601 |12.9 usec |11.6 usec |13.1 usec |12.4 usec |12.9 usec |12.6 usec |31.1 usec |121.7x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |isodate |13.6 usec |11.6 usec |13 usec |12.5 usec |12.9 usec |13.7 usec |46.7 usec |128.5x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |iso8601utils |N/A |N/A |N/A |20.8 usec |22.5 usec |23.5 usec |28.3 usec |166.8x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |PySO8601 |25.9 usec |20.5 usec |22.8 usec |24 usec |23.7 usec |24.3 usec |25.3 usec |244.4x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |zulu |26.3 usec |21.9 usec |25 usec |24.2 usec |24.9 usec |25.1 usec |N/A |248.8x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |aniso8601 |28 usec |25.4 usec |30.2 usec |29.7 usec |31.4 usec |33.8 usec |39.2 usec |264.4x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |maya |N/A |36.5 usec |41.3 usec |41.3 usec |40.7 usec |42.3 usec |N/A |376.1x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |python-dateutil |70.4 usec |64.4 usec |78.1 usec |78 usec |79.3 usec |83.3 usec |100 usec |664.3x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |arrow |74.1 usec |63.5 usec |75 usec |74 usec |74.7 usec |80.9 usec |148 usec |699.8x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |metomi-isodatetime |1.24 msec |1.33 msec |1.73 msec |1.73 msec |1.73 msec |1.86 msec |N/A |11719.3x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ - |moment |**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|N/A |2116377.5x | - +--------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+--------------------------------------------------+ + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + | Module |Relative slowdown (versus ciso8601, latest Python)| Python 3.12 | Python 3.11 | Python 3.10 | Python 3.9 | Python 3.8 | Python 3.7 | Python 2.7 | + +================================+==================================================+===============================+===============================+===============================+===============================+===============================+===============================+===============================+ + |ciso8601 |N/A |106 nsec |97 nsec |129 nsec |125 nsec |118 nsec |132 nsec |140 nsec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |backports.datetime_fromisoformat|1.1x |N/A |N/A |148 nsec |142 nsec |139 nsec |148 nsec |N/A | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |datetime (builtin) |1.9x |197 nsec |203 nsec |N/A |N/A |N/A |N/A |N/A | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |pendulum |2.2x |N/A |210 nsec |214 nsec |209 nsec |216 nsec |225 nsec |13.5 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |udatetime |7.8x |828 nsec |785 nsec |805 nsec |811 nsec |798 nsec |816 nsec |768 nsec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |str2date |73.6x |7.79 usec |6.86 usec |7.71 usec |7.77 usec |7.62 usec |8 usec |**Incorrect Result** (``None``)| + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |iso8601 |121.7x |12.9 usec |11.6 usec |13.1 usec |12.4 usec |12.9 usec |12.6 usec |31.1 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |isodate |128.5x |13.6 usec |11.6 usec |13 usec |12.5 usec |12.9 usec |13.7 usec |46.7 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |iso8601utils |166.8x |N/A |N/A |N/A |20.8 usec |22.5 usec |23.5 usec |28.3 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |PySO8601 |244.4x |25.9 usec |20.5 usec |22.8 usec |24 usec |23.7 usec |24.3 usec |25.3 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |zulu |248.8x |26.3 usec |21.9 usec |25 usec |24.2 usec |24.9 usec |25.1 usec |N/A | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |aniso8601 |264.4x |28 usec |25.4 usec |30.2 usec |29.7 usec |31.4 usec |33.8 usec |39.2 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |maya |376.1x |N/A |36.5 usec |41.3 usec |41.3 usec |40.7 usec |42.3 usec |N/A | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |python-dateutil |664.3x |70.4 usec |64.4 usec |78.1 usec |78 usec |79.3 usec |83.3 usec |100 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |arrow |699.8x |74.1 usec |63.5 usec |75 usec |74 usec |74.7 usec |80.9 usec |148 usec | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |metomi-isodatetime |11719.3x |1.24 msec |1.33 msec |1.73 msec |1.73 msec |1.73 msec |1.86 msec |N/A | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ + |moment |2116377.5x |**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|**Incorrect Result** (``None``)|N/A | + +--------------------------------+--------------------------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+-------------------------------+ ciso8601 takes 106 nsec, which is **1.9x faster than datetime (builtin)**, the next fastest Python 3.12 parser in this comparison. diff --git a/benchmarking/format_results.py b/benchmarking/format_results.py index 4c5b21d..d17b32e 100644 --- a/benchmarking/format_results.py +++ b/benchmarking/format_results.py @@ -128,7 +128,7 @@ def write_benchmarking_results(results_directory, output_file, baseline_module, writer = pytablewriter.RstGridTableWriter() formatted_python_versions = [f"Python {major}.{minor}" for major, minor in python_versions_by_modernity] - writer.headers = ["Module"] + (["Call"] if include_call else []) + formatted_python_versions + [f"Relative slowdown (versus {baseline_module}, latest Python)"] + writer.headers = ["Module"] + (["Call"] if include_call else []) + [f"Relative slowdown (versus {baseline_module}, latest Python)"] + formatted_python_versions[1:] writer.type_hints = [pytablewriter.String] * len(writer.headers) calling_codes = [calling_code[module] for module in modules_by_modern_speed] @@ -136,7 +136,7 @@ def write_benchmarking_results(results_directory, output_file, baseline_module, relative_slowdowns = [relative_slowdown(results[module], results[baseline_module]) if module != baseline_module else NOT_APPLICABLE for module in modules_by_modern_speed] writer.value_matrix = [ - [module] + ([calling_code[module]] if include_call else []) + performance_by_version + [relative_slowdown] for module, calling_code, performance_by_version, relative_slowdown in zip(modules_by_modern_speed, calling_codes, performance_results, relative_slowdowns) + [module] + ([calling_code[module]] if include_call else []) + [relative_slowdown] + performance_by_version for module, calling_code, performance_by_version, relative_slowdown in zip(modules_by_modern_speed, calling_codes, performance_results, relative_slowdowns) ] with open(output_file, "w") as fout: