diff -r d083b6ead156 Lib/urllib/parse.py --- a/Lib/urllib/parse.py Mon Mar 10 11:05:07 2014 +0100 +++ b/Lib/urllib/parse.py Mon Mar 10 13:40:17 2014 +0200 @@ -472,8 +472,7 @@ return _coerce_result(DefragResult(defrag, frag)) _hexdig = '0123456789ABCDEFabcdef' -_hextobyte = {(a + b).encode(): bytes([int(a + b, 16)]) - for a in _hexdig for b in _hexdig} +_hextobyte = None def unquote_to_bytes(string): """unquote_to_bytes('abc%20def') -> b'abc def'.""" @@ -490,6 +489,10 @@ return string res = [bits[0]] append = res.append + global _hextobyte + if _hextobyte is None: + _hextobyte = {(a + b).encode(): bytes([int(a + b, 16)]) + for a in _hexdig for b in _hexdig} for item in bits[1:]: try: append(_hextobyte[item[:2]])