Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3d731c59
Kaydet (Commit)
3d731c59
authored
Tem 30, 2015
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15138: Speed up base64.urlsafe_b64* considerably (2.7 backport).
üst
1edd2f62
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
base64.py
Lib/base64.py
+9
-5
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/base64.py
Dosyayı görüntüle @
3d731c59
...
...
@@ -7,6 +7,7 @@
import
re
import
struct
import
string
import
binascii
...
...
@@ -52,7 +53,7 @@ def b64encode(s, altchars=None):
# Strip off the trailing newline
encoded
=
binascii
.
b2a_base64
(
s
)[:
-
1
]
if
altchars
is
not
None
:
return
_translate
(
encoded
,
{
'+'
:
altchars
[
0
],
'/'
:
altchars
[
1
]}
)
return
encoded
.
translate
(
string
.
maketrans
(
b
'+/'
,
altchars
[:
2
])
)
return
encoded
...
...
@@ -68,7 +69,7 @@ def b64decode(s, altchars=None):
string.
"""
if
altchars
is
not
None
:
s
=
_translate
(
s
,
{
altchars
[
0
]:
'+'
,
altchars
[
1
]:
'/'
}
)
s
=
s
.
translate
(
string
.
maketrans
(
altchars
[:
2
],
'+/'
)
)
try
:
return
binascii
.
a2b_base64
(
s
)
except
binascii
.
Error
,
msg
:
...
...
@@ -92,13 +93,16 @@ def standard_b64decode(s):
"""
return
b64decode
(
s
)
_urlsafe_encode_translation
=
string
.
maketrans
(
b
'+/'
,
b
'-_'
)
_urlsafe_decode_translation
=
string
.
maketrans
(
b
'-_'
,
b
'+/'
)
def
urlsafe_b64encode
(
s
):
"""Encode a string using a url-safe Base64 alphabet.
s is the string to encode. The encoded string is returned. The alphabet
uses '-' instead of '+' and '_' instead of '/'.
"""
return
b64encode
(
s
,
'-_'
)
return
b64encode
(
s
)
.
translate
(
_urlsafe_encode_translation
)
def
urlsafe_b64decode
(
s
):
"""Decode a string encoded with the standard Base64 alphabet.
...
...
@@ -109,7 +113,7 @@ def urlsafe_b64decode(s):
The alphabet uses '-' instead of '+' and '_' instead of '/'.
"""
return
b64decode
(
s
,
'-_'
)
return
b64decode
(
s
.
translate
(
_urlsafe_decode_translation
)
)
...
...
@@ -200,7 +204,7 @@ def b32decode(s, casefold=False, map01=None):
# False, or the character to map the digit 1 (one) to. It should be
# either L (el) or I (eye).
if
map01
:
s
=
_translate
(
s
,
{
'0'
:
'O'
,
'1'
:
map01
}
)
s
=
s
.
translate
(
string
.
maketrans
(
b
'01'
,
b
'O'
+
map01
)
)
if
casefold
:
s
=
s
.
upper
()
# Strip off pad characters from the right. We need to count the pad
...
...
Misc/NEWS
Dosyayı görüntüle @
3d731c59
...
...
@@ -34,6 +34,8 @@ Core and Builtins
Library
-------
-
Issue
#
15138
:
Speed
up
base64
.
urlsafe_b64
{
en
,
de
}
code
considerably
.
-
Issue
#
23319
:
Fix
ctypes
.
BigEndianStructure
,
swap
correctly
bytes
.
Patch
written
by
Matthieu
Gautier
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment