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
af87f9f0
Kaydet (Commit)
af87f9f0
authored
May 17, 2010
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #1285086: Speed up urllib.quote and urllib.unquote for simple cases.
üst
4fc2a008
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
urllib.py
Lib/urllib.py
+26
-17
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/urllib.py
Dosyayı görüntüle @
af87f9f0
...
...
@@ -92,7 +92,7 @@ def urlretrieve(url, filename=None, reporthook=None, data=None):
def
urlcleanup
():
if
_urlopener
:
_urlopener
.
cleanup
()
_safe
map
s
.
clear
()
_safe
_quoter
s
.
clear
()
ftpcache
.
clear
()
# check for SSL
...
...
@@ -1163,15 +1163,18 @@ _hextochr = dict((a + b, chr(int(a + b, 16)))
def
unquote
(
s
):
"""unquote('abc
%20
def') -> 'abc def'."""
res
=
s
.
split
(
'
%
'
)
for
i
in
xrange
(
1
,
len
(
res
)):
item
=
res
[
i
]
# fastpath
if
len
(
res
)
==
1
:
return
s
s
=
res
[
0
]
for
item
in
res
[
1
:]:
try
:
res
[
i
]
=
_hextochr
[
item
[:
2
]]
+
item
[
2
:]
s
+
=
_hextochr
[
item
[:
2
]]
+
item
[
2
:]
except
KeyError
:
res
[
i
]
=
'
%
'
+
item
s
+
=
'
%
'
+
item
except
UnicodeDecodeError
:
res
[
i
]
=
unichr
(
int
(
item
[:
2
],
16
))
+
item
[
2
:]
return
""
.
join
(
res
)
s
+
=
unichr
(
int
(
item
[:
2
],
16
))
+
item
[
2
:]
return
s
def
unquote_plus
(
s
):
"""unquote('
%7
e/abc+def') -> '~/abc def'"""
...
...
@@ -1181,7 +1184,10 @@ def unquote_plus(s):
always_safe
=
(
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'abcdefghijklmnopqrstuvwxyz'
'0123456789'
'_.-'
)
_safemaps
=
{}
_safe_map
=
{}
for
i
,
c
in
zip
(
xrange
(
256
),
str
(
bytearray
(
xrange
(
256
)))):
_safe_map
[
c
]
=
c
if
(
i
<
128
and
c
in
always_safe
)
else
'
%
{:02X}'
.
format
(
i
)
_safe_quoters
=
{}
def
quote
(
s
,
safe
=
'/'
):
"""quote('abc def') -> 'abc
%20
def'
...
...
@@ -1204,18 +1210,21 @@ def quote(s, safe='/'):
called on a path where the existing slash characters are used as
reserved characters.
"""
# fastpath
if
not
s
:
return
s
cachekey
=
(
safe
,
always_safe
)
try
:
safe_map
=
_safemap
s
[
cachekey
]
(
quoter
,
safe
)
=
_safe_quoter
s
[
cachekey
]
except
KeyError
:
safe
+=
always_safe
safe_map
=
{}
for
i
in
range
(
256
):
c
=
chr
(
i
)
safe_map
[
c
]
=
(
c
in
safe
)
and
c
or
(
'
%%%02
X'
%
i
)
_safemaps
[
cachekey
]
=
safe_map
res
=
map
(
safe_map
.
__getitem__
,
s
)
return
''
.
join
(
res
)
safe
_map
=
_safe_map
.
copy
()
safe_map
.
update
([(
c
,
c
)
for
c
in
safe
])
quoter
=
safe_map
.
__getitem__
safe
=
always_safe
+
safe
_safe_quoters
[
cachekey
]
=
(
quoter
,
safe
)
if
not
s
.
rstrip
(
safe
):
return
s
return
''
.
join
(
map
(
quoter
,
s
)
)
def
quote_plus
(
s
,
safe
=
''
):
"""Quote the query fragment of a URL; replacing ' ' with '+'"""
...
...
Misc/NEWS
Dosyayı görüntüle @
af87f9f0
...
...
@@ -15,6 +15,8 @@ Core and Builtins
Library
-------
- Issue #1285086: Speed up urllib.quote and urllib.unquote for simple cases.
- Issue #8688: Distutils now recalculates MANIFEST everytime.
- Issue #5099: subprocess.Popen's __del__ method (and the methods it calls)
...
...
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