1. 28 Haz, 2003 1 kayıt (commit)
  2. 05 May, 2003 1 kayıt (commit)
    • Tim Peters's avatar
      SF patch 730594: assert from longobject.c, line 1215. · c7bc0b98
      Tim Peters yazdı
      Some version of gcc in the "RTEMS port running on the Coldfire (m5200)
      processor" generates bad code for a loop in long_from_binary_base(),
      comparing the wrong half of an int to a short.  The patch changes the
      decl of the short temp to be an int temp instead.  This "simplifies"
      the code enough that gcc no longer blows it.
      c7bc0b98
  3. 01 May, 2003 1 kayıt (commit)
  4. 17 Nis, 2003 1 kayıt (commit)
    • Thomas Heller's avatar
      SF # 595026: support for masks in getargs.c. · a4ea603b
      Thomas Heller yazdı
      New functions:
        unsigned long PyInt_AsUnsignedLongMask(PyObject *);
        unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
        unsigned long PyLong_AsUnsignedLongMask(PyObject *);
        unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
      
      New and changed format codes:
      
      b unsigned char 0..UCHAR_MAX
      B unsigned char none **
      h unsigned short 0..USHRT_MAX
      H unsigned short none **
      i int INT_MIN..INT_MAX
      I * unsigned int 0..UINT_MAX
      l long LONG_MIN..LONG_MAX
      k * unsigned long none
      L long long LLONG_MIN..LLONG_MAX
      K * unsigned long long none
      
      Notes:
      
      * New format codes.
      
      ** Changed from previous "range-and-a-half" to "none"; the
      range-and-a-half checking wasn't particularly useful.
      
      New test test_getargs2.py, to verify all this.
      a4ea603b
  5. 29 Mar, 2003 1 kayıt (commit)
  6. 23 Şub, 2003 1 kayıt (commit)
  7. 03 Şub, 2003 1 kayıt (commit)
  8. 02 Şub, 2003 4 kayıt (commit)
    • Tim Peters's avatar
      long_from_binary_base(): Sped this a little by computing the # of bits · 1a3b19a6
      Tim Peters yazdı
      needed outside the first loop.
      1a3b19a6
    • Tim Peters's avatar
      Tightened a too-generous assert. · efb9625b
      Tim Peters yazdı
      efb9625b
    • Tim Peters's avatar
      long(string, base) now takes time linear in len(string) when base is a · bf2674be
      Tim Peters yazdı
      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.
      bf2674be
    • Tim Peters's avatar
      cPickle.c: Full support for the new LONG1 and LONG4. Added comments. · ee1a53cb
      Tim Peters yazdı
      Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
      no need to do things like multiply by sizeof(char) in hairy malloc
      arguments.  Fixed an undetected-overflow bug in readline_file().
      
      longobject.c:  Fixed a really stupid bug in the new _PyLong_NumBits.
      
      pickle.py:  Fixed stupid bug in save_long():  When proto is 2, it
      wrote LONG1 or LONG4, but forgot to return then -- it went on to
      append the proto 1 LONG opcode too.
      Fixed equally stupid cancelling bugs in load_long1() and
      load_long4():  they *returned* the unpickled long instead of pushing
      it on the stack.  The return values were ignored.  Tests passed
      before only because save_long() pickled the long twice.
      
      Fixed bugs in encode_long().
      
      Noted that decode_long() is quadratic-time despite our hopes,
      because long(string, 16) is still quadratic-time in len(string).
      It's hex() that's linear-time.  I don't know a way to make decode_long()
      linear-time in Python, short of maybe transforming the 256's-complement
      bytes into marshal's funky internal format, and letting marshal decode
      that.  It would be more valuable to make long(string, 16) linear time.
      
      pickletester.py:  Added a global "protocols" vector so tests can try
      all the protocols in a sane way.  Changed test_ints() and test_unicode()
      to do so.  Added a new test_long(), but the tail end of it is disabled
      because it "takes forever" under pickle.py (but runs very quickly under
      cPickle:  cPickle proto 2 for longs is linear-time).
      ee1a53cb
  9. 31 Ock, 2003 2 kayıt (commit)
  10. 29 Ock, 2003 1 kayıt (commit)
  11. 28 Ock, 2003 1 kayıt (commit)
  12. 30 Ara, 2002 1 kayıt (commit)
  13. 19 Kas, 2002 1 kayıt (commit)
  14. 06 Kas, 2002 1 kayıt (commit)
  15. 03 Eyl, 2002 1 kayıt (commit)
  16. 20 Agu, 2002 1 kayıt (commit)
    • Tim Peters's avatar
      long_format(), long_lshift(): Someone on c.l.py is trying to boost · 0d2d87d2
      Tim Peters yazdı
      SHIFT and MASK, and widen digit.  One problem is that code of the form
      
          digit << small_integer
      
      implicitly assumes that the result fits in an int or unsigned int
      (platform-dependent, but "int sized" in any case), since digit is
      promoted "just" to int or unsigned via the usual integer promotions.
      But if digit is typedef'ed as unsigned int, this loses information.
      The cure for this is just to cast digit to twodigits first.
      0d2d87d2
  17. 15 Agu, 2002 3 kayıt (commit)
  18. 14 Agu, 2002 2 kayıt (commit)
  19. 13 Agu, 2002 3 kayıt (commit)
  20. 12 Agu, 2002 12 kayıt (commit)
    • Tim Peters's avatar
    • Tim Peters's avatar
      Added new function k_lopsided_mul(), which is much more efficient than · 6000464d
      Tim Peters yazdı
      k_mul() when inputs have vastly different sizes, and a little more
      efficient when they're close to a factor of 2 out of whack.
      
      I consider this done now, although I'll set up some more correctness
      tests to run overnight.
      6000464d
    • Tim Peters's avatar
      k_mul(): Moved an assert down. In a debug build, interrupting a · 547607c4
      Tim Peters yazdı
      multiply via Ctrl+C could cause a NULL-pointer dereference due to
      the assert.
      547607c4
    • Tim Peters's avatar
      k_mul(): Heh -- I checked in two fixes for the last problem. Only keep · 70b041bb
      Tim Peters yazdı
      the good one <wink>.  Also checked in a test-aid by mistake.
      70b041bb
    • Tim Peters's avatar
      k_mul(): White-box testing turned up that (ah+al)*(bh+bl) can, in rare · d8b2173e
      Tim Peters yazdı
      cases, overflow the allocated result object by 1 bit.  In such cases,
      it would have been brought back into range if we subtracted al*bl and
      ah*bh from it first, but I don't want to do that because it hurts cache
      behavior.  Instead we just ignore the excess bit when it appears -- in
      effect, this is forcing unsigned mod BASE**(asize + bsize) arithmetic
      in a case where that doesn't happen all by itself.
      d8b2173e
    • Tim Peters's avatar
      x_mul(): Made life easier for C optimizers in the "grade school" · 115c888b
      Tim Peters yazdı
      algorithm.  MSVC 6 wasn't impressed <wink>.
      
      Something odd:  the x_mul algorithm appears to get substantially worse
      than quadratic time as the inputs grow larger:
      
      bits in each input   x_mul time   k_mul time
      ------------------   ----------   ----------
                   15360         0.01         0.00
                   30720         0.04         0.01
                   61440         0.16         0.04
                  122880         0.64         0.14
                  245760         2.56         0.40
                  491520        10.76         1.23
                  983040        71.28         3.69
                 1966080       459.31        11.07
      
      That is, x_mul is perfectly quadratic-time until a little burp at
      2.56->10.76, and after that goes to hell in a hurry.  Under Karatsuba,
      doubling the input size "should take" 3 times longer instead of 4, and
      that remains the case throughout this range.  I conclude that my "be nice
      to the cache" reworkings of k_mul() are paying.
      115c888b
    • Tim Peters's avatar
      k_mul() and long_mul(): I'm confident that the Karatsuba algorithm is · d64c1def
      Tim Peters yazdı
      correct now, so added some final comments, did some cleanup, and enabled
      it for all long-int multiplies.  The KARAT envar no longer matters,
      although I left some #if 0'ed code in there for my own use (temporary).
      k_mul() is still much slower than x_mul() if the inputs have very
      differenent sizes, and that still needs to be addressed.
      d64c1def
    • Tim Peters's avatar
      k_mul: Rearranged computation for better cache use. Ignored overflow · 738eda74
      Tim Peters yazdı
      (it's possible, but should be harmless -- this requires more thought,
      and allocating enough space in advance to prevent it requires exactly
      as much thought, to know exactly how much that is -- the end result
      certainly fits in the allocated space -- hmm, but that's really all
      the thought it needs!  borrows/carries out of the high digits really
      are harmless).
      738eda74
    • Tim Peters's avatar
      x_mul(): This failed to normalize its result. · 44121a6b
      Tim Peters yazdı
      k_mul():  This didn't allocate enough result space when one input had
      more than twice as many bits as the other.  This was partly hidden by
      that x_mul() didn't normalize its result.
      
      The Karatsuba recurrence is pretty much hosed if the inputs aren't
      roughly the same size.  If one has at least twice as many bits as the
      other, we get a degenerate case where the "high half" of the smaller
      input is 0.  Added a special case for that, for speed, but despite that
      it helped, this can still be much slower than the "grade school" method.
      It seems to take a really wild imbalance to trigger that; e.g., a
      2**22-bit input times a 1000-bit input on my box runs about twice as slow
      under k_mul than under x_mul.  This still needs to be addressed.
      
      I'm also not sure that allocating a->ob_size + b->ob_size digits is
      enough, given that this is computing k = (ah+al)*(bh+bl) instead of
      k = (ah-al)*(bl-bh); i.e., it's certainly enough for the final result,
      but it's vaguely possible that adding in the "artificially" large k may
      overflow that temporarily.  If so, an assert will trigger in the debug
      build, but we'll probably compute the right result anyway(!).
      44121a6b
    • Tim Peters's avatar
      Introduced helper functions v_iadd and v_isub, for in-place digit-vector · 877a2126
      Tim Peters yazdı
      addition and subtraction.  Reworked the tail end of k_mul() to use them.
      This saves oodles of one-shot longobject allocations (this is a triply-
      recursive routine, so saving one allocation in the body saves 3**n
      allocations at depth n; we actually save 2 allocations in the body).
      877a2126
    • Tim Peters's avatar
      fc07e568
    • Tim Peters's avatar
      k_mul(): Repaired typo in comment. · 18c15b9b
      Tim Peters yazdı
      18c15b9b