fastpybase64 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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2020 The simdutf authors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2026 Daniel Lemire
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ 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, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include vendor/*.h vendor/*.cpp vendor/simdutf-LICENSE-* src/*.cpp
2
+ include bench.py doc/make_charts.py
3
+ recursive-include tests *.py
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastpybase64
3
+ Version: 0.1.0
4
+ Summary: Fast Base64 encoding and decoding for Python, built on simdutf
5
+ Author-email: Daniel Lemire <daniel@lemire.me>
6
+ License-Expression: Apache-2.0 OR MIT
7
+ Project-URL: Homepage, https://github.com/simdutf/fastpybase64
8
+ Project-URL: Repository, https://github.com/simdutf/fastpybase64
9
+ Project-URL: Issues, https://github.com/simdutf/fastpybase64/issues
10
+ Keywords: base64,simdutf,simd,performance,encoding
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: C++
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE-APACHE
26
+ License-File: LICENSE-MIT
27
+ License-File: vendor/simdutf-LICENSE-APACHE
28
+ License-File: vendor/simdutf-LICENSE-MIT
29
+ Provides-Extra: test
30
+ Requires-Dist: pytest; extra == "test"
31
+ Provides-Extra: bench
32
+ Requires-Dist: pybase64; extra == "bench"
33
+ Dynamic: license-file
34
+
35
+ # fastpybase64
36
+
37
+ [![Tests](https://github.com/simdutf/fastpybase64/actions/workflows/tests.yml/badge.svg)](https://github.com/simdutf/fastpybase64/actions/workflows/tests.yml)
38
+
39
+ A Python binding for the base64 functions of
40
+ [simdutf](https://github.com/simdutf/simdutf), the library that Node.js uses
41
+ for base64. It is a drop-in replacement for the standard
42
+ library's `base64` module: every function returns the same bytes and raises
43
+ the same exceptions as its counterpart in `base64`, for every input. It
44
+ decodes up to 80 times faster than the standard library and up to 13 times
45
+ faster than [pybase64](https://github.com/mayeut/pybase64), and it is
46
+ several times faster than both on small inputs.
47
+
48
+ With pip:
49
+
50
+ ```sh
51
+ pip install fastpybase64
52
+ ```
53
+
54
+ With uv:
55
+
56
+ ```sh
57
+ uv pip install fastpybase64 # in a uv project: uv add fastpybase64
58
+ ```
59
+
60
+ Wheels are built for Linux, macOS and Windows, for Python 3.10 to 3.14,
61
+ including free-threaded Python 3.14.
62
+
63
+ ## Usage
64
+
65
+ ```python
66
+ import fastpybase64 as base64
67
+
68
+ base64.b64encode(b"hello") # b'aGVsbG8='
69
+ base64.b64decode("aGVsbG8=") # b'hello'
70
+ base64.b64decode(b"aGVsbG8=", validate=True) # b'hello'
71
+ base64.urlsafe_b64encode(b"\xfb\xff") # b'-_8='
72
+ base64.encodebytes(data) # MIME: lines of 76 characters
73
+ ```
74
+
75
+ | function | |
76
+ |---|---|
77
+ | `b64encode(s, altchars=None)` | standard alphabet, or any two replacement characters for `+` and `/` |
78
+ | `b64decode(s, altchars=None, validate=False)` | |
79
+ | `standard_b64encode(s)`, `standard_b64decode(s)` | |
80
+ | `urlsafe_b64encode(s)`, `urlsafe_b64decode(s)` | alphabet with `-` and `_` |
81
+ | `encodebytes(s)`, `decodebytes(s)` | MIME style: a newline after every 76 characters |
82
+ | `get_implementation()` | the kernel simdutf selected for this processor (`icelake`, `haswell`, `arm64`, ...) |
83
+ | `simdutf_version`, `__version__` | versions of simdutf and of fastpybase64 |
84
+
85
+ The functions accept what `base64` accepts: `bytes`, `bytearray`,
86
+ `memoryview` and other buffers, and ASCII `str` for the decoders.
87
+
88
+ ### Same results as `base64`
89
+
90
+ simdutf decodes base64 following the WHATWG forgiving-base64 rules, used by
91
+ `atob` in web browsers. These rules differ from those of Python's `binascii`
92
+ module: simdutf skips ASCII spaces and accepts missing padding, whereas the
93
+ standard library requires padding and, with `validate=True`, rejects spaces.
94
+ fastpybase64 keeps Python's behavior. Each call decodes with simdutf, then a
95
+ cheap check confirms that `base64` would return the same bytes for this
96
+ input. When it cannot confirm it, fastpybase64 calls `base64` with the same
97
+ arguments and returns its result or lets its exception propagate. So invalid
98
+ input raises exactly the `binascii.Error` that `base64` would raise, with
99
+ the same message, and the rare inputs where `base64` is lenient in odd ways
100
+ (characters after the padding, for example) give the same bytes.
101
+
102
+ * With `validate=False` (the default), spaces, newlines and other characters
103
+ outside the alphabet are ignored, as in `base64`. simdutf skips spaces and
104
+ line breaks while it decodes: 1 MiB of MIME data (a newline every 76
105
+ characters) decodes at 12.0 GB/s on an Apple M4 Max, against 14.3 GB/s
106
+ without newlines (pybase64: 4.1 GB/s, `base64`: 1.3 GB/s).
107
+ * With `validate=True`, any character outside the alphabet, including a
108
+ space or a newline, raises `binascii.Error`.
109
+ * Characters after the padding are handled as in the version of Python you
110
+ run: Python 3.13 and earlier stop decoding at the padding, Python 3.14
111
+ continues or raises.
112
+ * `urlsafe_b64decode`, like the standard library, accepts both alphabets
113
+ (`+/` and `-_`).
114
+ * An `altchars` other than `b"+/"` and `b"-_"` is handled by encoding with
115
+ simdutf and then replacing the two characters; decoding with such an
116
+ alphabet is left to `base64`.
117
+
118
+ ### Threads
119
+
120
+ The GIL is released while encoding or decoding 64 KiB or more, so several
121
+ threads can work at once. The module is marked free-threading compatible
122
+ (`Py_MOD_GIL_NOT_USED`), so importing it on a free-threaded build of Python
123
+ does not enable the GIL. Do not change a `bytearray` while another thread
124
+ encodes or decodes it: the result would be unpredictable (its size cannot
125
+ change, so memory stays safe).
126
+
127
+ ## Build and test
128
+
129
+ Python 3.10 or newer, and a C++17 compiler (clang, GCC or MSVC). The simdutf
130
+ 9.3.1 amalgamation is in `vendor/`. Only its base64 functions are compiled
131
+ (see `setup.py`).
132
+
133
+ pip:
134
+
135
+ ```sh
136
+ python3 -m venv .venv
137
+ . .venv/bin/activate
138
+ python -m pip install -U pip
139
+ python -m pip install -e ".[test]"
140
+ pytest tests
141
+ ```
142
+
143
+ uv:
144
+
145
+ ```sh
146
+ uv venv
147
+ . .venv/bin/activate
148
+ uv pip install -e ".[test]"
149
+ pytest tests
150
+ ```
151
+
152
+ The tests compare every function with `base64`, results and exceptions, on
153
+ inputs of every length from 0 to 199 bytes and larger ones, on the edge cases
154
+ of padding and of characters outside the alphabet, on every supported input
155
+ type, on wrong arguments, and on thousands of randomly corrupted inputs.
156
+
157
+ `bench.py` compares fastpybase64 with `base64` and pybase64 (the `bench`
158
+ extra) from 16 bytes to 16 MiB:
159
+
160
+ ```sh
161
+ python -m pip install -e ".[bench]"
162
+ python bench.py
163
+ python bench.py --sizes 64,4096,65536 --ops b64encode,b64decode
164
+ ```
165
+
166
+ ## Benchmarks
167
+
168
+ Intel Xeon Gold 6548N (Emerald Rapids), one core, Python 3.14.6,
169
+ fastpybase64 0.1.0 (simdutf 9.3.1, `icelake` kernel), pybase64 1.5.1 (its
170
+ AVX512VBMI kernel), random bytes. Speeds are in GB/s of binary data, for
171
+ encoding and decoding alike (higher is better).
172
+
173
+ ### Decoding
174
+
175
+ <picture>
176
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/simdutf/fastpybase64/main/doc/perf_decode_dark.png">
177
+ <img src="https://raw.githubusercontent.com/simdutf/fastpybase64/main/doc/perf_decode.png" width="80%" alt="Decoding 64 KiB: fastpybase64 b64decode 32.66 GB/s, fastpybase64 validate=True 30.81, pybase64 validate=True 14.65, pybase64 b64decode 3.44, base64 validate=True 0.55, base64 b64decode 0.50">
178
+ </picture>
179
+
180
+ | function | size | `base64` | pybase64 | fastpybase64 |
181
+ |---|---:|---:|---:|---:|
182
+ | `b64decode` | 64 B | 0.24 | 0.44 | **0.96** |
183
+ | | 4 KiB | 0.48 | 3.06 | **22.42** |
184
+ | | 64 KiB | 0.50 | 3.44 | **32.66** |
185
+ | | 1 MiB | 0.50 | 3.47 | **19.38** |
186
+ | `b64decode(validate=True)` | 64 B | 0.19 | 0.23 | **0.43** |
187
+ | | 4 KiB | 0.53 | 7.25 | **14.61** |
188
+ | | 64 KiB | 0.55 | 14.65 | **30.81** |
189
+ | | 1 MiB | 0.55 | 15.24 | **19.55** |
190
+ | `urlsafe_b64decode` | 64 B | 0.16 | 0.16 | **0.98** |
191
+ | | 64 KiB | 0.41 | 2.52 | **33.86** |
192
+ | `decodebytes` | 64 KiB | 0.49 | | **12.10** |
193
+
194
+ pybase64 is fast only with `validate=True`; by default (`validate=False`, as
195
+ in `base64`) and in `urlsafe_b64decode`, it is 4 to 13 times slower than
196
+ fastpybase64 from 4 KiB on. pybase64 has no
197
+ `decodebytes`.
198
+
199
+ ### Encoding
200
+
201
+ <picture>
202
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/simdutf/fastpybase64/main/doc/perf_encode_dark.png">
203
+ <img src="https://raw.githubusercontent.com/simdutf/fastpybase64/main/doc/perf_encode.png" width="80%" alt="Encoding 64 KiB: pybase64 b64encode 32.46 GB/s, fastpybase64 b64encode 30.68, fastpybase64 urlsafe_b64encode 30.31, pybase64 urlsafe_b64encode 9.84, base64 b64encode 0.98, base64 urlsafe_b64encode 0.69">
204
+ </picture>
205
+
206
+ | function | size | `base64` | pybase64 | fastpybase64 |
207
+ |---|---:|---:|---:|---:|
208
+ | `b64encode` | 64 B | 0.43 | 0.39 | **1.34** |
209
+ | | 4 KiB | 0.95 | 16.15 | **31.18** |
210
+ | | 64 KiB | 0.98 | 32.46 | 30.68 |
211
+ | | 1 MiB | 0.75 | 18.43 | 17.92 |
212
+ | `urlsafe_b64encode` | 64 B | 0.30 | 0.21 | **1.34** |
213
+ | | 64 KiB | 0.69 | 9.84 | **30.31** |
214
+ | `encodebytes` | 64 B | 0.11 | 0.50 | **1.29** |
215
+ | | 64 KiB | 0.38 | 1.18 | **22.20** |
216
+
217
+ From 64 KiB on, `b64encode` runs at the same speed in pybase64 and
218
+ fastpybase64: both use the same AVX-512 algorithm, and which one is ahead
219
+ changes from run to run (within 6%). On smaller inputs, and for the URL-safe
220
+ alphabet and MIME line breaks, fastpybase64 is faster.
221
+
222
+ ### Small inputs
223
+
224
+ On small inputs, the cost of the call dominates. fastpybase64 parses its
225
+ arguments without creating objects and writes the result directly into the
226
+ `bytes` object it returns.
227
+
228
+ <picture>
229
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/simdutf/fastpybase64/main/doc/perf_small_dark.png">
230
+ <img src="https://raw.githubusercontent.com/simdutf/fastpybase64/main/doc/perf_small.png" width="80%" alt="Time per call for 64 bytes: fastpybase64 b64encode 48 ns, pybase64 164 ns, base64 149 ns; fastpybase64 b64decode 67 ns, pybase64 145 ns, base64 267 ns">
231
+ </picture>
232
+
233
+ ### Apple M4 Max
234
+
235
+ macOS, Python 3.14.5, simdutf's `arm64` (NEON) kernel, pybase64 with its
236
+ NEON kernel. GB/s:
237
+
238
+ | function | size | `base64` | pybase64 | fastpybase64 |
239
+ |---|---:|---:|---:|---:|
240
+ | `b64encode` | 64 B | 0.56 | 0.77 | **1.62** |
241
+ | | 64 KiB | 1.13 | 23.30 | **23.70** |
242
+ | `b64decode` | 64 B | 0.33 | 0.61 | **1.16** |
243
+ | | 64 KiB | 0.92 | 4.23 | **13.94** |
244
+ | `b64decode(validate=True)` | 64 KiB | 0.95 | 12.16 | **13.71** |
245
+ | `urlsafe_b64decode` | 64 KiB | 0.71 | 3.06 | **13.00** |
246
+ | `encodebytes` | 64 KiB | 0.47 | 8.53 | **12.82** |
247
+
248
+ ## Releases
249
+
250
+ `./release.sh X.Y.Z` sets the version in `pyproject.toml` and
251
+ `src/fastpybase64.cpp`, runs the tests in a fresh virtual environment,
252
+ commits, tags `vX.Y.Z` and pushes. The tag starts the `buildwheels` workflow,
253
+ which builds the wheels and the source distribution and uploads them to PyPI.
254
+
255
+ ## References
256
+
257
+ * Daniel Lemire, [Fast Forgiving Base64 Decoding with SIMD Instructions](https://dl.acm.org/doi/10.1145/3859286), ACM Transactions on Architecture and Code Optimization, 2026.
258
+ * Wojciech Muła, Daniel Lemire, [Base64 encoding and decoding at almost the speed of a memory copy](https://arxiv.org/abs/1910.05109), Software: Practice and Experience 50 (2), 2020.
259
+ * Wojciech Muła, Daniel Lemire, [Faster Base64 Encoding and Decoding using AVX2 Instructions](https://arxiv.org/abs/1704.00605), ACM Transactions on the Web 12 (3), 2018.
260
+
261
+ ## License
262
+
263
+ Apache-2.0 or MIT, at your option, like simdutf.