fastuuidv7 0.1.4__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.
@@ -0,0 +1,196 @@
1
+ name: Python Benchmark
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - 'python/**'
8
+ - 'src/**'
9
+ - '.github/workflows/benchmark-python.yml'
10
+ pull_request:
11
+ branches: [main]
12
+ paths:
13
+ - 'python/**'
14
+ - 'src/**'
15
+ workflow_dispatch:
16
+
17
+ jobs:
18
+ benchmark:
19
+ name: Benchmark on ${{ matrix.platform.name }}
20
+ runs-on: ${{ matrix.platform.runner }}
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ platform:
25
+ # Linux x86_64
26
+ - name: Linux x86_64
27
+ runner: ubuntu-latest
28
+ target: x86_64
29
+ # Windows x86_64
30
+ - name: Windows x86_64
31
+ runner: windows-latest
32
+ target: x86_64
33
+ # macOS ARM (Apple Silicon)
34
+ - name: macOS ARM64
35
+ runner: macos-latest
36
+ target: aarch64
37
+
38
+ steps:
39
+ - name: Check out repository
40
+ uses: actions/checkout@v4
41
+
42
+ - name: Set up Python
43
+ uses: actions/setup-python@v5
44
+ with:
45
+ python-version: "3.11"
46
+
47
+ - name: Install Rust toolchain
48
+ uses: dtolnay/rust-toolchain@stable
49
+
50
+ - name: Build Python package (optimized)
51
+ uses: PyO3/maturin-action@v1
52
+ with:
53
+ working-directory: python
54
+ target: ${{ matrix.platform.target }}
55
+ args: --release --out dist --find-interpreter
56
+ sccache: 'true'
57
+ manylinux: auto
58
+
59
+ - name: Install built package
60
+ shell: bash
61
+ run: |
62
+ pip install --find-links python/dist fastuuidv7
63
+
64
+ - name: Install comparison packages
65
+ shell: bash
66
+ run: |
67
+ pip install uuid6 || true
68
+ pip install uuid7 || true
69
+ pip install fastuuid7 || true
70
+
71
+ - name: Display system information
72
+ shell: bash
73
+ run: |
74
+ echo "=== System Information ==="
75
+ python --version
76
+ python -c "import platform; print(f'Platform: {platform.platform()}')"
77
+ python -c "import platform; print(f'Processor: {platform.processor()}')"
78
+ python -c "import platform; print(f'Machine: {platform.machine()}')"
79
+ echo ""
80
+
81
+ - name: Run benchmark
82
+ shell: bash
83
+ run: |
84
+ echo "=== Running Benchmark ==="
85
+ python python/bench/bench.py
86
+ echo ""
87
+
88
+ - name: Run extended performance test
89
+ shell: bash
90
+ run: |
91
+ echo "=== Extended Performance Test ==="
92
+ python -c "
93
+ import fastuuidv7
94
+ import time
95
+
96
+ # Warm up
97
+ for _ in range(10000):
98
+ fastuuidv7.gen_id_str()
99
+
100
+ # Benchmark different call counts
101
+ for count in [100_000, 1_000_000, 10_000_000]:
102
+ start = time.perf_counter()
103
+ for _ in range(count):
104
+ fastuuidv7.gen_id_str()
105
+ elapsed = time.perf_counter() - start
106
+ ops_per_sec = count / elapsed
107
+ ns_per_call = elapsed * 1e9 / count
108
+ print(f'{count:>10,} calls: {ops_per_sec:>15,.0f} ops/s ({ns_per_call:>6.1f} ns/call)')
109
+ "
110
+ echo ""
111
+
112
+ - name: Memory efficiency test
113
+ shell: bash
114
+ run: |
115
+ echo "=== Memory Efficiency Test ==="
116
+ python -c "
117
+ import fastuuidv7
118
+ import sys
119
+
120
+ # Test that we're not leaking memory
121
+ ids = []
122
+ for _ in range(100_000):
123
+ ids.append(fastuuidv7.gen_id_str())
124
+
125
+ # Check string size
126
+ sample = ids[0]
127
+ print(f'UUID string length: {len(sample)} chars')
128
+ print(f'UUID string size: {sys.getsizeof(sample)} bytes')
129
+ print(f'Sample UUID: {sample}')
130
+ print(f'Generated {len(ids):,} UUIDs successfully')
131
+ "
132
+ echo ""
133
+
134
+ - name: Comparison with uuid.uuid4
135
+ shell: bash
136
+ run: |
137
+ echo "=== Comparison with uuid.uuid4() ==="
138
+ python -c "
139
+ import fastuuidv7
140
+ import uuid
141
+ import time
142
+
143
+ count = 1_000_000
144
+
145
+ # Benchmark fastuuidv7
146
+ start = time.perf_counter()
147
+ for _ in range(count):
148
+ fastuuidv7.gen_id_str()
149
+ elapsed_v7 = time.perf_counter() - start
150
+
151
+ # Benchmark uuid.uuid4
152
+ start = time.perf_counter()
153
+ for _ in range(count):
154
+ str(uuid.uuid4())
155
+ elapsed_v4 = time.perf_counter() - start
156
+
157
+ speedup = elapsed_v4 / elapsed_v7
158
+
159
+ print(f'fastuuidv7.gen_id_str(): {count/elapsed_v7:>15,.0f} ops/s')
160
+ print(f'uuid.uuid4() + str(): {count/elapsed_v4:>15,.0f} ops/s')
161
+ print(f'Speedup: {speedup:.2f}x faster')
162
+ "
163
+ echo ""
164
+
165
+ - name: Upload benchmark results
166
+ if: always()
167
+ uses: actions/upload-artifact@v4
168
+ with:
169
+ name: benchmark-results-${{ matrix.platform.name }}
170
+ path: |
171
+ python/bench/
172
+ retention-days: 30
173
+
174
+ summary:
175
+ name: Benchmark Summary
176
+ runs-on: ubuntu-latest
177
+ needs: benchmark
178
+ if: always()
179
+ steps:
180
+ - name: Download all benchmark results
181
+ uses: actions/download-artifact@v4
182
+ with:
183
+ path: results
184
+
185
+ - name: Create summary
186
+ run: |
187
+ echo "# Python Benchmark Results" >> $GITHUB_STEP_SUMMARY
188
+ echo "" >> $GITHUB_STEP_SUMMARY
189
+ echo "Benchmarks completed for:" >> $GITHUB_STEP_SUMMARY
190
+ echo "- Linux x86_64" >> $GITHUB_STEP_SUMMARY
191
+ echo "- Windows x86_64" >> $GITHUB_STEP_SUMMARY
192
+ echo "- macOS ARM64 (Apple Silicon)" >> $GITHUB_STEP_SUMMARY
193
+ echo "" >> $GITHUB_STEP_SUMMARY
194
+ echo "See individual job logs for detailed performance metrics." >> $GITHUB_STEP_SUMMARY
195
+
196
+ # Made with Bob
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main", "master" ]
6
+ pull_request:
7
+ branches: [ "main", "master" ]
8
+
9
+ env:
10
+ CARGO_TERM_COLOR: always
11
+
12
+ jobs:
13
+ test:
14
+ name: Test ${{ matrix.os }}
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ os: [ubuntu-latest, macos-latest, windows-latest]
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - name: Install Rust toolchain
23
+ uses: dtolnay/rust-toolchain@stable
24
+ - name: Build
25
+ run: cargo build --verbose
26
+ - name: Run tests
27
+ run: cargo test --verbose
28
+ - name: Run bench
29
+ run: cargo bench
30
+
31
+ test-fallback:
32
+ name: Test Fallback (i686)
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+ - name: Install dependencies
37
+ run: |
38
+ sudo apt-get update
39
+ sudo apt-get install -y gcc-multilib
40
+ - name: Install Rust toolchain
41
+ uses: dtolnay/rust-toolchain@stable
42
+ with:
43
+ targets: i686-unknown-linux-gnu
44
+ - name: Build
45
+ run: cargo build --verbose --target i686-unknown-linux-gnu
46
+ - name: Run tests
47
+ run: cargo test --verbose --target i686-unknown-linux-gnu
48
+ - name: Run bench
49
+ run: cargo bench
@@ -0,0 +1,149 @@
1
+ name: Publish Python Package
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+ workflow_dispatch:
8
+ inputs:
9
+ target:
10
+ description: "Where to publish the package"
11
+ required: true
12
+ default: "testpypi"
13
+ type: choice
14
+ options:
15
+ - testpypi
16
+ - pypi
17
+
18
+ jobs:
19
+ build-wheels:
20
+ name: Build wheels on ${{ matrix.platform.os }} (${{ matrix.platform.target }})
21
+ runs-on: ${{ matrix.platform.runner }}
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ platform:
26
+ # Linux x86_64
27
+ - runner: ubuntu-latest
28
+ os: linux
29
+ target: x86_64
30
+ # Linux aarch64 (ARM64)
31
+ - runner: ubuntu-latest
32
+ os: linux
33
+ target: aarch64
34
+ # Linux armv7
35
+ - runner: ubuntu-latest
36
+ os: linux
37
+ target: armv7
38
+ # macOS x86_64 (Intel)
39
+ - runner: macos-15-intel
40
+ os: macos
41
+ target: x86_64
42
+ # macOS aarch64 (Apple Silicon)
43
+ - runner: macos-latest
44
+ os: macos
45
+ target: aarch64
46
+ # Windows x86_64
47
+ - runner: windows-latest
48
+ os: windows
49
+ target: x86_64
50
+ # Windows aarch64 (ARM64) - Disabled due to lack of Python dev libraries in CI
51
+ # Cross-compiling Python extensions for Windows ARM64 is not currently supported
52
+ # - runner: windows-latest
53
+ # os: windows
54
+ # target: aarch64
55
+
56
+ steps:
57
+ - name: Check out repository
58
+ uses: actions/checkout@v4
59
+
60
+ - name: Set up Python
61
+ uses: actions/setup-python@v5
62
+ with:
63
+ python-version: "3.11"
64
+
65
+ - name: Install Rust toolchain
66
+ uses: dtolnay/rust-toolchain@stable
67
+
68
+ - name: Build wheels
69
+ uses: PyO3/maturin-action@v1
70
+ with:
71
+ working-directory: python
72
+ target: ${{ matrix.platform.target }}
73
+ args: --release --out dist --find-interpreter
74
+ sccache: 'true'
75
+ manylinux: auto
76
+
77
+ - name: Upload wheels
78
+ uses: actions/upload-artifact@v4
79
+ with:
80
+ name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.target }}
81
+ path: python/dist
82
+
83
+ build-sdist:
84
+ name: Build source distribution
85
+ runs-on: ubuntu-latest
86
+ steps:
87
+ - name: Check out repository
88
+ uses: actions/checkout@v4
89
+
90
+ - name: Set up Python
91
+ uses: actions/setup-python@v5
92
+ with:
93
+ python-version: "3.11"
94
+
95
+ - name: Install Rust toolchain
96
+ uses: dtolnay/rust-toolchain@stable
97
+
98
+ - name: Build sdist
99
+ uses: PyO3/maturin-action@v1
100
+ with:
101
+ working-directory: python
102
+ command: sdist
103
+ args: --out dist
104
+
105
+ - name: Upload sdist
106
+ uses: actions/upload-artifact@v4
107
+ with:
108
+ name: sdist
109
+ path: python/dist
110
+
111
+ publish:
112
+ name: Publish to ${{ github.event_name == 'release' && 'PyPI' || inputs.target }}
113
+ runs-on: ubuntu-latest
114
+ needs: [build-wheels, build-sdist]
115
+ permissions:
116
+ contents: read
117
+ id-token: write
118
+ environment:
119
+ name: ${{ github.event_name == 'release' && 'pypi' || inputs.target }}
120
+
121
+ steps:
122
+ - name: Download all artifacts
123
+ uses: actions/download-artifact@v4
124
+ with:
125
+ path: dist
126
+ merge-multiple: true
127
+
128
+ - name: List distribution files
129
+ run: ls -lh dist/
130
+
131
+ - name: Check package metadata
132
+ run: |
133
+ pip install twine
134
+ twine check dist/*
135
+
136
+ - name: Publish to TestPyPI
137
+ if: github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
138
+ uses: pypa/gh-action-pypi-publish@release/v1
139
+ with:
140
+ repository-url: https://test.pypi.org/legacy/
141
+ packages-dir: dist/
142
+
143
+ - name: Publish to PyPI
144
+ if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.target == 'pypi')
145
+ uses: pypa/gh-action-pypi-publish@release/v1
146
+ with:
147
+ packages-dir: dist/
148
+
149
+ # Made with Bob
@@ -0,0 +1,62 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ env:
9
+ CARGO_TERM_COLOR: always
10
+
11
+ jobs:
12
+ release:
13
+ name: Release
14
+ runs-on: ubuntu-latest
15
+ permissions:
16
+ contents: write
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Install Rust toolchain
21
+ uses: dtolnay/rust-toolchain@stable
22
+
23
+ - name: Cache cargo registry
24
+ uses: actions/cache@v4
25
+ with:
26
+ path: |
27
+ ~/.cargo/bin/
28
+ ~/.cargo/registry/cache/
29
+ ~/.cargo/git/db/
30
+ target/
31
+ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32
+ restore-keys: |
33
+ ${{ runner.os }}-cargo-
34
+
35
+ - name: Build release
36
+ run: cargo build --release
37
+
38
+ - name: Run tests
39
+ run: cargo test --release
40
+
41
+ - name: Create GitHub Release
42
+ uses: softprops/action-gh-release@v2
43
+ with:
44
+ generate_release_notes: true
45
+ env:
46
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47
+
48
+ publish-crates-io:
49
+ name: Publish to crates.io
50
+ runs-on: ubuntu-latest
51
+ needs: release
52
+ environment: release
53
+ steps:
54
+ - uses: actions/checkout@v4
55
+
56
+ - name: Install Rust toolchain
57
+ uses: dtolnay/rust-toolchain@stable
58
+
59
+ - name: Publish to crates.io
60
+ run: cargo publish --allow-dirty
61
+ env:
62
+ CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
@@ -0,0 +1,27 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ debug
4
+ target
5
+
6
+ # These are backup files generated by rustfmt
7
+ **/*.rs.bk
8
+
9
+ # MSVC Windows builds of rustc generate these, which store debugging information
10
+ *.pdb
11
+
12
+ # Generated by cargo mutants
13
+ # Contains mutation testing data
14
+ **/mutants.out*/
15
+
16
+ # RustRover
17
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
18
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
19
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
20
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
21
+ #.idea/
22
+
23
+ .serena
24
+
25
+ # Added by cargo
26
+
27
+ /target