[Python-checkins] python/dist/src/Lib pickle.py,1.138,1.139

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 01 Feb 2003 23:51:34 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv7771/Lib

Modified Files:
	pickle.py 
Log Message:
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.


Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.138
retrieving revision 1.139
diff -C2 -d -r1.138 -r1.139
*** pickle.py	2 Feb 2003 02:57:52 -0000	1.138
--- pickle.py	2 Feb 2003 07:51:32 -0000	1.139
***************
*** 1428,1434 ****
      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.
--- 1428,1431 ----
***************
*** 1454,1458 ****
          return 0L
      ashex = _binascii.hexlify(data[::-1])
!     n = long(ashex, 16) # quadratic time
      if data[-1] >= '\x80':
          n -= 1L << (nbytes * 8)
--- 1451,1455 ----
          return 0L
      ashex = _binascii.hexlify(data[::-1])
!     n = long(ashex, 16) # quadratic time before Python 2.3; linear now
      if data[-1] >= '\x80':
          n -= 1L << (nbytes * 8)