diff options
author | Tim Peters <tim.peters@gmail.com> | 2003-02-02 07:51:32 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2003-02-02 07:51:32 (GMT) |
commit | bf2674be0e95787cdeb154091b7377e30b2827bf (patch) | |
tree | 05ccb3b212ff3027587b948678959f7b6ca61546 /Lib/pickle.py | |
parent | 06dd8cf5e4100303714f9e3f72b3c52330fdd51c (diff) | |
download | cpython-bf2674be0e95787cdeb154091b7377e30b2827bf.zip cpython-bf2674be0e95787cdeb154091b7377e30b2827bf.tar.gz cpython-bf2674be0e95787cdeb154091b7377e30b2827bf.tar.bz2 |
long(string, base) now takes time linear in len(string) when base is a
power of 2. Enabled the tail end of test_long() in pickletester.py
because it no longer takes forever when run from test_pickle.py.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index ba0e38b..4e80cca 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -1427,9 +1427,6 @@ def encode_long(x): binary = _binascii.unhexlify(ashex) return binary[::-1] -# XXX OOPS! This is still quadratic-time. While hex(n) is linear-time -# XXX in the # of digits in n, long(s, 16) is still quadratic-time -# XXX in len(s). def decode_long(data): r"""Decode a long from a two's complement little-endian binary string. @@ -1453,7 +1450,7 @@ def decode_long(data): if nbytes == 0: return 0L ashex = _binascii.hexlify(data[::-1]) - n = long(ashex, 16) # quadratic time + n = long(ashex, 16) # quadratic time before Python 2.3; linear now if data[-1] >= '\x80': n -= 1L << (nbytes * 8) return n |