pdateutil 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pdateutil-0.1.0/.github/workflows/ci.yml +136 -0
- pdateutil-0.1.0/.gitignore +14 -0
- pdateutil-0.1.0/Cargo.lock +133 -0
- pdateutil-0.1.0/Cargo.toml +19 -0
- pdateutil-0.1.0/LICENSE +39 -0
- pdateutil-0.1.0/PKG-INFO +73 -0
- pdateutil-0.1.0/README.md +43 -0
- pdateutil-0.1.0/SECURITY.md +11 -0
- pdateutil-0.1.0/benchmarks/bench.py +63 -0
- pdateutil-0.1.0/pyproject.toml +54 -0
- pdateutil-0.1.0/python/pdateutil/__init__.py +8 -0
- pdateutil-0.1.0/python/pdateutil/_pdateutil.pyi +61 -0
- pdateutil-0.1.0/python/pdateutil/easter.py +38 -0
- pdateutil-0.1.0/python/pdateutil/parser/__init__.py +199 -0
- pdateutil-0.1.0/python/pdateutil/parser/isoparser.py +55 -0
- pdateutil-0.1.0/python/pdateutil/py.typed +0 -0
- pdateutil-0.1.0/python/pdateutil/relativedelta.py +533 -0
- pdateutil-0.1.0/python/pdateutil/rrule.py +439 -0
- pdateutil-0.1.0/python/pdateutil/tz.py +387 -0
- pdateutil-0.1.0/python/pdateutil/utils.py +27 -0
- pdateutil-0.1.0/src/isoparse.rs +526 -0
- pdateutil-0.1.0/src/lib.rs +457 -0
- pdateutil-0.1.0/src/parser.rs +523 -0
- pdateutil-0.1.0/src/rrule.rs +603 -0
- pdateutil-0.1.0/src/simd.rs +260 -0
- pdateutil-0.1.0/tests/test_adversarial.py +58 -0
- pdateutil-0.1.0/tests/test_concurrency_and_leaks.py +49 -0
- pdateutil-0.1.0/tests/test_differential.py +83 -0
- pdateutil-0.1.0/tests/test_ecosystem.py +81 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
tags: ["v*"]
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint-and-test-rust:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
18
|
+
with:
|
|
19
|
+
components: rustfmt, clippy
|
|
20
|
+
- uses: Swatinem/rust-cache@v2
|
|
21
|
+
- run: cargo fmt --check
|
|
22
|
+
- run: cargo clippy --all-targets -- -D warnings
|
|
23
|
+
- run: cargo test --lib
|
|
24
|
+
|
|
25
|
+
build-wheels:
|
|
26
|
+
strategy:
|
|
27
|
+
fail-fast: false
|
|
28
|
+
matrix:
|
|
29
|
+
include:
|
|
30
|
+
- os: ubuntu-latest
|
|
31
|
+
target: x86_64
|
|
32
|
+
args: --release --compatibility manylinux2014
|
|
33
|
+
run_tests: true
|
|
34
|
+
- os: ubuntu-latest
|
|
35
|
+
target: musl-x86_64
|
|
36
|
+
args: --release --compatibility musllinux_1_2
|
|
37
|
+
run_tests: false
|
|
38
|
+
- os: ubuntu-24.04-arm
|
|
39
|
+
target: aarch64
|
|
40
|
+
args: --release --compatibility manylinux2014
|
|
41
|
+
run_tests: true
|
|
42
|
+
- os: ubuntu-24.04-arm
|
|
43
|
+
target: musl-aarch64
|
|
44
|
+
args: --release --compatibility musllinux_1_2
|
|
45
|
+
run_tests: false
|
|
46
|
+
- os: macos-15
|
|
47
|
+
target: aarch64
|
|
48
|
+
args: --release
|
|
49
|
+
run_tests: true
|
|
50
|
+
- os: macos-15
|
|
51
|
+
target: x86_64
|
|
52
|
+
args: --release --target x86_64-apple-darwin
|
|
53
|
+
run_tests: false
|
|
54
|
+
- os: windows-latest
|
|
55
|
+
target: x64
|
|
56
|
+
args: --release
|
|
57
|
+
run_tests: true
|
|
58
|
+
runs-on: ${{ matrix.os }}
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/checkout@v4
|
|
61
|
+
- uses: actions/setup-python@v5
|
|
62
|
+
with:
|
|
63
|
+
python-version: "3.12"
|
|
64
|
+
- uses: PyO3/maturin-action@v1
|
|
65
|
+
with:
|
|
66
|
+
command: build
|
|
67
|
+
args: ${{ matrix.args }} -o dist
|
|
68
|
+
manylinux: auto
|
|
69
|
+
- name: Check wheel metadata
|
|
70
|
+
shell: bash
|
|
71
|
+
run: |
|
|
72
|
+
python -m pip install --upgrade pip twine
|
|
73
|
+
twine check dist/*.whl
|
|
74
|
+
- name: Install and test abi3 wheel
|
|
75
|
+
if: matrix.run_tests
|
|
76
|
+
shell: bash
|
|
77
|
+
run: |
|
|
78
|
+
python -m pip install pytest hypothesis python-dateutil mypy ruff abi3audit
|
|
79
|
+
python -m pip install dist/*.whl
|
|
80
|
+
pytest -v
|
|
81
|
+
- name: Static typing, stubtest, and abi3audit (Linux)
|
|
82
|
+
if: runner.os == 'Linux' && matrix.run_tests
|
|
83
|
+
run: |
|
|
84
|
+
ruff format --check python tests
|
|
85
|
+
ruff check python tests
|
|
86
|
+
mypy --strict python/pdateutil
|
|
87
|
+
stubtest --ignore-disjoint-base pdateutil
|
|
88
|
+
abi3audit --strict dist/*.whl
|
|
89
|
+
- uses: actions/upload-artifact@v4
|
|
90
|
+
with:
|
|
91
|
+
name: wheels-${{ matrix.os }}-${{ matrix.target }}
|
|
92
|
+
path: dist/*.whl
|
|
93
|
+
|
|
94
|
+
build-sdist:
|
|
95
|
+
runs-on: ubuntu-latest
|
|
96
|
+
steps:
|
|
97
|
+
- uses: actions/checkout@v4
|
|
98
|
+
- uses: PyO3/maturin-action@v1
|
|
99
|
+
with:
|
|
100
|
+
command: sdist
|
|
101
|
+
args: -o dist
|
|
102
|
+
- uses: actions/upload-artifact@v4
|
|
103
|
+
with:
|
|
104
|
+
name: sdist
|
|
105
|
+
path: dist/*.tar.gz
|
|
106
|
+
|
|
107
|
+
publish:
|
|
108
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
109
|
+
needs: [lint-and-test-rust, build-wheels, build-sdist]
|
|
110
|
+
runs-on: ubuntu-latest
|
|
111
|
+
environment: pypi
|
|
112
|
+
permissions:
|
|
113
|
+
id-token: write
|
|
114
|
+
attestations: write
|
|
115
|
+
contents: write
|
|
116
|
+
steps:
|
|
117
|
+
- uses: actions/download-artifact@v4
|
|
118
|
+
with:
|
|
119
|
+
path: dist
|
|
120
|
+
merge-multiple: true
|
|
121
|
+
- name: Attest build provenance (SLSA)
|
|
122
|
+
uses: actions/attest-build-provenance@v2
|
|
123
|
+
with:
|
|
124
|
+
subject-path: "dist/*"
|
|
125
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
126
|
+
with:
|
|
127
|
+
packages-dir: dist/
|
|
128
|
+
- name: Generate SHA-256 checksums
|
|
129
|
+
run: (cd dist && sha256sum *.whl *.tar.gz) > SHA256SUMS.txt
|
|
130
|
+
- name: Create GitHub Release
|
|
131
|
+
uses: softprops/action-gh-release@v2
|
|
132
|
+
with:
|
|
133
|
+
generate_release_notes: true
|
|
134
|
+
files: |
|
|
135
|
+
dist/*
|
|
136
|
+
SHA256SUMS.txt
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "heck"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "libc"
|
|
13
|
+
version = "0.2.191"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "once_cell"
|
|
19
|
+
version = "1.21.4"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "pdateutil"
|
|
25
|
+
version = "0.1.0"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pyo3",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[[package]]
|
|
31
|
+
name = "portable-atomic"
|
|
32
|
+
version = "1.15.0"
|
|
33
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
34
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "proc-macro2"
|
|
38
|
+
version = "1.0.107"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
41
|
+
dependencies = [
|
|
42
|
+
"unicode-ident",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "pyo3"
|
|
47
|
+
version = "0.28.3"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12"
|
|
50
|
+
dependencies = [
|
|
51
|
+
"libc",
|
|
52
|
+
"once_cell",
|
|
53
|
+
"portable-atomic",
|
|
54
|
+
"pyo3-build-config",
|
|
55
|
+
"pyo3-ffi",
|
|
56
|
+
"pyo3-macros",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[[package]]
|
|
60
|
+
name = "pyo3-build-config"
|
|
61
|
+
version = "0.28.3"
|
|
62
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
63
|
+
checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e"
|
|
64
|
+
dependencies = [
|
|
65
|
+
"target-lexicon",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
[[package]]
|
|
69
|
+
name = "pyo3-ffi"
|
|
70
|
+
version = "0.28.3"
|
|
71
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
72
|
+
checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e"
|
|
73
|
+
dependencies = [
|
|
74
|
+
"libc",
|
|
75
|
+
"pyo3-build-config",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
[[package]]
|
|
79
|
+
name = "pyo3-macros"
|
|
80
|
+
version = "0.28.3"
|
|
81
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
82
|
+
checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813"
|
|
83
|
+
dependencies = [
|
|
84
|
+
"proc-macro2",
|
|
85
|
+
"pyo3-macros-backend",
|
|
86
|
+
"quote",
|
|
87
|
+
"syn",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[[package]]
|
|
91
|
+
name = "pyo3-macros-backend"
|
|
92
|
+
version = "0.28.3"
|
|
93
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
94
|
+
checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb"
|
|
95
|
+
dependencies = [
|
|
96
|
+
"heck",
|
|
97
|
+
"proc-macro2",
|
|
98
|
+
"pyo3-build-config",
|
|
99
|
+
"quote",
|
|
100
|
+
"syn",
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
[[package]]
|
|
104
|
+
name = "quote"
|
|
105
|
+
version = "1.0.47"
|
|
106
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
107
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
108
|
+
dependencies = [
|
|
109
|
+
"proc-macro2",
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
[[package]]
|
|
113
|
+
name = "syn"
|
|
114
|
+
version = "2.0.119"
|
|
115
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
116
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
117
|
+
dependencies = [
|
|
118
|
+
"proc-macro2",
|
|
119
|
+
"quote",
|
|
120
|
+
"unicode-ident",
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
[[package]]
|
|
124
|
+
name = "target-lexicon"
|
|
125
|
+
version = "0.13.6"
|
|
126
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
127
|
+
checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
|
|
128
|
+
|
|
129
|
+
[[package]]
|
|
130
|
+
name = "unicode-ident"
|
|
131
|
+
version = "1.0.27"
|
|
132
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
133
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "pdateutil"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
license = "MIT OR Apache-2.0"
|
|
6
|
+
description = "Fast drop-in replacement for python-dateutil in Rust"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
[lib]
|
|
10
|
+
name = "_pdateutil"
|
|
11
|
+
crate-type = ["cdylib"]
|
|
12
|
+
|
|
13
|
+
[dependencies]
|
|
14
|
+
pyo3 = { version = "0.28", features = ["abi3-py39", "extension-module"] }
|
|
15
|
+
|
|
16
|
+
[profile.release]
|
|
17
|
+
lto = true
|
|
18
|
+
codegen-units = 1
|
|
19
|
+
opt-level = 3
|
pdateutil-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Copyright (c) 2026, gatewaytofredom
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
20
|
+
|
|
21
|
+
--------------------------------------------------------------------------------
|
|
22
|
+
Portions of the Python compatibility layer (easter, relativedelta, tz, rrule
|
|
23
|
+
interfaces) are adapted from python-dateutil:
|
|
24
|
+
|
|
25
|
+
Copyright 2017- Paul Ganssle <paul@ganssle.io>
|
|
26
|
+
Copyright 2017- dateutil contributors
|
|
27
|
+
|
|
28
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
29
|
+
you may not use this file except in compliance with the License.
|
|
30
|
+
You may obtain a copy of the License at
|
|
31
|
+
|
|
32
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
|
|
34
|
+
Copyright (c) 2003-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
|
|
35
|
+
Copyright (c) 2012-2014 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
|
|
36
|
+
Copyright (c) 2014-2016 - Yaron de Leeuw <me@jarondl.net>
|
|
37
|
+
Copyright (c) 2015- - Paul Ganssle <paul@ganssle.io>
|
|
38
|
+
Copyright (c) 2015- - dateutil contributors
|
|
39
|
+
All rights reserved. (BSD 3-Clause License)
|
pdateutil-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pdateutil
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
17
|
+
Classifier: Programming Language :: Rust
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Summary: Fast drop-in replacement for python-dateutil in Python
|
|
21
|
+
Keywords: dateutil,datetime,iso8601,rrule,parser,rust
|
|
22
|
+
Author-email: gateway12 <gateway12@laindex.net>
|
|
23
|
+
License: MIT OR Apache-2.0
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
26
|
+
Project-URL: Homepage, https://github.com/gatewaytofredom/pdateutil
|
|
27
|
+
Project-URL: Issues, https://github.com/gatewaytofredom/pdateutil/issues
|
|
28
|
+
Project-URL: Repository, https://github.com/gatewaytofredom/pdateutil
|
|
29
|
+
|
|
30
|
+
# pdateutil
|
|
31
|
+
|
|
32
|
+
[](https://github.com/gatewaytofredom/pdateutil/actions/workflows/ci.yml)
|
|
33
|
+
[](https://pypi.org/project/pdateutil/)
|
|
34
|
+
[](https://pypi.org/project/pdateutil/)
|
|
35
|
+
[](https://github.com/gatewaytofredom/pdateutil/blob/main/LICENSE)
|
|
36
|
+
|
|
37
|
+
Drop-in replacement for `python-dateutil` for fast date parsing, ISO-8601 timestamps, and recurrence rules in Python — up to **19x faster** on common parsing workloads.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install pdateutil
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Prebuilt wheels are included for Linux, macOS, and Windows (Python 3.9+, no Rust toolchain needed).
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from pdateutil.parser import isoparse, parse
|
|
51
|
+
from pdateutil.rrule import DAILY, rrule
|
|
52
|
+
|
|
53
|
+
dt = isoparse("2024-07-15T14:32:10Z")
|
|
54
|
+
dt2 = parse("Mon, 15 Jul 2024 14:32:10 GMT")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Performance
|
|
58
|
+
|
|
59
|
+
| Workload | `python-dateutil` | `pdateutil` (x86-64 AVX2) | `pdateutil` (Apple M4 NEON) |
|
|
60
|
+
|---|---:|---:|---:|
|
|
61
|
+
| `isoparse` (ISO-8601 + tz) | 4.16 us (x86) / 2.88 us (M4) | 0.78 us (5.32x) | 0.55 us (5.28x) |
|
|
62
|
+
| `parse` (RFC-2822 / HTTP) | 29.99 us (x86) / 18.08 us (M4) | 1.55 us (19.32x) | 1.34 us (13.50x) |
|
|
63
|
+
| `rrule` (DAILY, count=100) | 103.11 us (x86) / 71.67 us (M4) | 13.62 us (7.57x) | 10.92 us (6.56x) |
|
|
64
|
+
|
|
65
|
+
## Under the hood
|
|
66
|
+
|
|
67
|
+
- Written in Rust (PyO3) with zero external runtime dependencies and runtime SIMD dispatch (AVX2 / SSE2 / ARM64 NEON)
|
|
68
|
+
- Compact `cp39-abi3` wheel with PEP 561 type stubs (`py.typed` + `_pdateutil.pyi`)
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT / Apache-2.0 / BSD-3-Clause
|
|
73
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# pdateutil
|
|
2
|
+
|
|
3
|
+
[](https://github.com/gatewaytofredom/pdateutil/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/pdateutil/)
|
|
5
|
+
[](https://pypi.org/project/pdateutil/)
|
|
6
|
+
[](https://github.com/gatewaytofredom/pdateutil/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
Drop-in replacement for `python-dateutil` for fast date parsing, ISO-8601 timestamps, and recurrence rules in Python — up to **19x faster** on common parsing workloads.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install pdateutil
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Prebuilt wheels are included for Linux, macOS, and Windows (Python 3.9+, no Rust toolchain needed).
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from pdateutil.parser import isoparse, parse
|
|
22
|
+
from pdateutil.rrule import DAILY, rrule
|
|
23
|
+
|
|
24
|
+
dt = isoparse("2024-07-15T14:32:10Z")
|
|
25
|
+
dt2 = parse("Mon, 15 Jul 2024 14:32:10 GMT")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Performance
|
|
29
|
+
|
|
30
|
+
| Workload | `python-dateutil` | `pdateutil` (x86-64 AVX2) | `pdateutil` (Apple M4 NEON) |
|
|
31
|
+
|---|---:|---:|---:|
|
|
32
|
+
| `isoparse` (ISO-8601 + tz) | 4.16 us (x86) / 2.88 us (M4) | 0.78 us (5.32x) | 0.55 us (5.28x) |
|
|
33
|
+
| `parse` (RFC-2822 / HTTP) | 29.99 us (x86) / 18.08 us (M4) | 1.55 us (19.32x) | 1.34 us (13.50x) |
|
|
34
|
+
| `rrule` (DAILY, count=100) | 103.11 us (x86) / 71.67 us (M4) | 13.62 us (7.57x) | 10.92 us (6.56x) |
|
|
35
|
+
|
|
36
|
+
## Under the hood
|
|
37
|
+
|
|
38
|
+
- Written in Rust (PyO3) with zero external runtime dependencies and runtime SIMD dispatch (AVX2 / SSE2 / ARM64 NEON)
|
|
39
|
+
- Compact `cp39-abi3` wheel with PEP 561 type stubs (`py.typed` + `_pdateutil.pyi`)
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT / Apache-2.0 / BSD-3-Clause
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a Vulnerability
|
|
4
|
+
|
|
5
|
+
Please report security vulnerabilities privately using GitHub's **Private Vulnerability Reporting** feature on the **Security** tab of this repository (or email `gateway@laindex.net`).
|
|
6
|
+
|
|
7
|
+
Please include:
|
|
8
|
+
- A minimal reproducer (input bytes/string and affected version)
|
|
9
|
+
- Expected vs. observed behavior (e.g., crash, quadratic CPU / ReDoS, memory issue)
|
|
10
|
+
|
|
11
|
+
We aim to acknowledge reports within 48 hours and ship a verified fix promptly.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Head-to-head microbenchmarks: `pdateutil` vs `python-dateutil`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime
|
|
6
|
+
import statistics
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import dateutil.parser as ref_parser
|
|
11
|
+
import dateutil.rrule as ref_rrule
|
|
12
|
+
except ImportError:
|
|
13
|
+
ref_parser = None # type: ignore[assignment]
|
|
14
|
+
ref_rrule = None # type: ignore[assignment]
|
|
15
|
+
|
|
16
|
+
import pdateutil.parser as our_parser
|
|
17
|
+
import pdateutil.rrule as our_rrule
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def bench(fn: object, iters: int, runs: int = 3) -> float:
|
|
21
|
+
callable_fn = fn # type: ignore[assignment]
|
|
22
|
+
callable_fn()
|
|
23
|
+
times: list[float] = []
|
|
24
|
+
for _ in range(runs):
|
|
25
|
+
t0 = time.perf_counter()
|
|
26
|
+
for _ in range(iters):
|
|
27
|
+
callable_fn()
|
|
28
|
+
times.append((time.perf_counter() - t0) * 1e6 / iters)
|
|
29
|
+
return statistics.median(times)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def main() -> None:
|
|
33
|
+
iso_s = "2024-07-15T14:32:10.123456+05:30"
|
|
34
|
+
gen_s = "Mon, 15 Jul 2024 14:32:10 GMT"
|
|
35
|
+
dtstart = datetime.datetime(2024, 1, 1, 9, 0)
|
|
36
|
+
|
|
37
|
+
cases = [
|
|
38
|
+
("isoparse (ISO-8601 + tz)", lambda: our_parser.isoparse(iso_s), lambda: ref_parser.isoparse(iso_s), 5000),
|
|
39
|
+
("parse (RFC-2822 / HTTP)", lambda: our_parser.parse(gen_s), lambda: ref_parser.parse(gen_s), 3000),
|
|
40
|
+
(
|
|
41
|
+
"rrule (DAILY count=100)",
|
|
42
|
+
lambda: list(our_rrule.rrule(our_rrule.DAILY, dtstart=dtstart, count=100)),
|
|
43
|
+
lambda: list(ref_rrule.rrule(ref_rrule.DAILY, dtstart=dtstart, count=100)),
|
|
44
|
+
500,
|
|
45
|
+
),
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
print(f"{'Benchmark':30s} {'dateutil (us)':>14s} {'pdateutil (us)':>15s} {'Speedup':>10s}")
|
|
49
|
+
print("-" * 73)
|
|
50
|
+
for name, our_fn, ref_fn, iters in cases:
|
|
51
|
+
our_us = bench(our_fn, iters)
|
|
52
|
+
if ref_parser is not None:
|
|
53
|
+
ref_us = bench(ref_fn, iters)
|
|
54
|
+
speedup = f"{ref_us / our_us:.2f}x"
|
|
55
|
+
ref_str = f"{ref_us:14.2f}"
|
|
56
|
+
else:
|
|
57
|
+
speedup = "N/A"
|
|
58
|
+
ref_str = "N/A"
|
|
59
|
+
print(f"{name:30s} {ref_str:>14s} {our_us:15.2f} {speedup:>10s}")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
main()
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.7,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pdateutil"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Fast drop-in replacement for python-dateutil in Python"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT OR Apache-2.0" }
|
|
12
|
+
authors = [{ name = "gateway12", email = "gateway12@laindex.net" }]
|
|
13
|
+
keywords = ["dateutil", "datetime", "iso8601", "rrule", "parser", "rust"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
28
|
+
"Programming Language :: Rust",
|
|
29
|
+
"Typing :: Typed",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/gatewaytofredom/pdateutil"
|
|
34
|
+
Repository = "https://github.com/gatewaytofredom/pdateutil"
|
|
35
|
+
Issues = "https://github.com/gatewaytofredom/pdateutil/issues"
|
|
36
|
+
|
|
37
|
+
[tool.maturin]
|
|
38
|
+
python-source = "python"
|
|
39
|
+
module-name = "pdateutil._pdateutil"
|
|
40
|
+
features = ["pyo3/abi3-py39", "pyo3/extension-module"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
testpaths = ["tests"]
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 100
|
|
47
|
+
target-version = "py39"
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint]
|
|
50
|
+
select = ["E", "F", "W", "I", "UP", "B"]
|
|
51
|
+
|
|
52
|
+
[tool.mypy]
|
|
53
|
+
python_version = "3.10"
|
|
54
|
+
strict = true
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"isoparse_fast",
|
|
6
|
+
"parse_fast",
|
|
7
|
+
"parse_isodate_fast",
|
|
8
|
+
"parse_isotime_fast",
|
|
9
|
+
"parse_tzstr_fast",
|
|
10
|
+
"rrule_generate",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
def isoparse_fast(
|
|
14
|
+
dt_str: str | bytes | bytearray,
|
|
15
|
+
sep: str | bytes | bytearray | None = None,
|
|
16
|
+
tzutc_cls: Any = None,
|
|
17
|
+
tzoffset_cls: Any = None,
|
|
18
|
+
) -> datetime.datetime: ...
|
|
19
|
+
def parse_isodate_fast(datestr: str | bytes | bytearray) -> datetime.date: ...
|
|
20
|
+
def parse_isotime_fast(
|
|
21
|
+
timestr: str | bytes | bytearray,
|
|
22
|
+
tzutc_cls: Any = None,
|
|
23
|
+
tzoffset_cls: Any = None,
|
|
24
|
+
) -> datetime.time: ...
|
|
25
|
+
def parse_tzstr_fast(
|
|
26
|
+
tzstr: str | bytes | bytearray,
|
|
27
|
+
zero_as_utc: bool = True,
|
|
28
|
+
tzutc_cls: Any = None,
|
|
29
|
+
tzoffset_cls: Any = None,
|
|
30
|
+
) -> datetime.tzinfo | None: ...
|
|
31
|
+
def parse_fast(
|
|
32
|
+
timestr: str | bytes | bytearray,
|
|
33
|
+
dayfirst: bool = False,
|
|
34
|
+
yearfirst: bool = False,
|
|
35
|
+
ignoretz: bool = False,
|
|
36
|
+
fuzzy: bool = False,
|
|
37
|
+
fuzzy_with_tokens: bool = False,
|
|
38
|
+
default_tuple: tuple[int, int, int, int, int, int, int] = ...,
|
|
39
|
+
current_year: int = 2026,
|
|
40
|
+
tzutc_cls: Any = None,
|
|
41
|
+
tzoffset_cls: Any = None,
|
|
42
|
+
) -> Any: ...
|
|
43
|
+
def rrule_generate(
|
|
44
|
+
freq: int,
|
|
45
|
+
dtstart: tuple[int, int, int, int, int, int, int],
|
|
46
|
+
interval: int = 1,
|
|
47
|
+
wkst: int = 0,
|
|
48
|
+
count: int | None = None,
|
|
49
|
+
until: tuple[int, int, int, int, int, int, int] | None = None,
|
|
50
|
+
bysetpos: list[int] = ...,
|
|
51
|
+
bymonth: list[int] = ...,
|
|
52
|
+
bymonthday: list[int] = ...,
|
|
53
|
+
byyearday: list[int] = ...,
|
|
54
|
+
byeaster: list[int] = ...,
|
|
55
|
+
byweekno: list[int] = ...,
|
|
56
|
+
byweekday: list[tuple[int, int | None]] = ...,
|
|
57
|
+
byhour: list[int] = ...,
|
|
58
|
+
byminute: list[int] = ...,
|
|
59
|
+
bysecond: list[int] = ...,
|
|
60
|
+
max_items: int | None = None,
|
|
61
|
+
) -> list[datetime.datetime]: ...
|