Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2c1fdf3

Browse files
authored
gh-141968: Usebytearray.take_bytes inbase64_b32encode and_b32decode (#141971)
1 parent2ff8608 commit2c1fdf3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

‎Lib/base64.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def _b32encode(alphabet, s):
193193
encoded[-3:]=b'==='
194194
elifleftover==4:
195195
encoded[-1:]=b'='
196-
returnbytes(encoded)
196+
returnencoded.take_bytes()
197197

198198
def_b32decode(alphabet,s,casefold=False,map01=None):
199199
# Delay the initialization of the table to not waste memory
@@ -238,7 +238,7 @@ def _b32decode(alphabet, s, casefold=False, map01=None):
238238
last=acc.to_bytes(5)# big endian
239239
leftover= (43-5*padchars)//8# 1: 4, 3: 3, 4: 2, 6: 1
240240
decoded[-5:]=last[:leftover]
241-
returnbytes(decoded)
241+
returndecoded.take_bytes()
242242

243243

244244
defb32encode(s):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove a data copy from:func:`base64.b32decode` and
2+
:func:`base64.b32encode` by using:func:`bytearray.take_bytes`.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp