summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Issue #19171: speed some cases of 3-argument long pow().Tim Peters2013-10-051-4/+10
| | | | | | | | | Reduce the base by the modulus when the base is larger than the modulus. This can unboundedly speed the "startup costs" of doing modular exponentiation, particularly in cases where the base is much larger than the modulus. Original patch by Armin Rigo, inspired by https://github.com/pyca/ed25519. (grafted from f34c59494420765b013136ca93f63b716d9f1d30)
* Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-191-0/+18
| | | | | | | when result of PyInt_AsLong() or PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
* Issue #16761: Raise TypeError when int() or long() called with base argument ↵Serhiy Storchaka2012-12-281-1/+7
| | | | only.
* Issue #14783: Backport changes from 3.2.Chris Jerdonek2012-10-081-6/+12
|
* #11565: Fix several typos. Patch by Piotr Kasprzyk.Ezio Melotti2011-03-161-1/+1
|
* #11515: fix several typos. Patch by Piotr Kasprzyk.Ezio Melotti2011-03-151-1/+1
|
* Wrap multiline macros in a 'do {} while(0)', for safety.Mark Dickinson2010-05-091-37/+43
|
* Post-detabification cleanup: whitespace fixes and long line rewraps only.Mark Dickinson2010-05-091-159/+155
|
* Untabify C files. Will watch buildbots.Antoine Pitrou2010-05-091-3374/+3374
|
* Issue #8659: Remove redundant ABS calls. Thanks Daniel Stutzbach.Mark Dickinson2010-05-081-5/+2
|
* Issue #8328: Silence Visual Studio warnings.Stefan Krah2010-04-071-6/+6
|
* Silence a 'comparison between signed and unsigned integer expressions' gcc ↵Mark Dickinson2010-04-061-1/+1
| | | | warning.
* Issue #8259: Get rid of 'outrageous left shift count' error whenMark Dickinson2010-04-061-14/+6
| | | | | left-shifting an integer by more than 2**31 on a 64-bit machine. Also convert shift counts to a Py_ssize_t instead of a C long.
* Issue #7767: Add new C-API function PyLong_AsLongLongAndOverflow, aMark Dickinson2010-01-301-0/+104
| | | | | long long variant of PyLong_AsLongAndOverflow. Patch by Case Van Horsen.
* Refactor some longobject internals: PyLong_AsDouble and _PyLong_AsScaledDoubleMark Dickinson2010-01-021-221/+146
| | | | | | | | (the latter renamed to _PyLong_Frexp) now use the same core code. The exponent produced by _PyLong_Frexp now has type Py_ssize_t instead of the previously used int, and no longer needs scaling by PyLong_SHIFT. This frees the math module from having to know anything about the PyLong implementation. This closes issue #5576.
* Issue #1811: Improve accuracy and consistency of true division for integers.Mark Dickinson2009-12-271-31/+252
|
* Issue #7528: Backport PyLong_AsLongAndOverflow from py3k to trunk.Mark Dickinson2009-12-211-31/+101
| | | | Thanks Case Van Horsen for the patch.
* Issue #1087418: Small performance boost for bitwise operations on longs.Mark Dickinson2009-10-251-66/+100
| | | | Initial patch by Gregory Smith; some tweaks added.
* Style/consistency/nano-optimization nit: replace occurrences ofMark Dickinson2009-09-281-6/+6
| | | | | | | | | | (high_bits << PyLong_SHIFT) + low_bits with (high_bits << PyLong_SHIFT) | low_bits in Objects/longobject.c. Motivation: - shouldn't unnecessarily mix bit ops with arithmetic ops (style) - this pattern should be spelt the same way thoughout (consistency) - it's very very very slightly faster: no need to worry about carries to the high digit (nano-optimization).
* Silence MSVC compiler warnings.Mark Dickinson2009-09-211-2/+3
|
* Issue #6713: Improve performance of str(n) and repr(n) for integers nMark Dickinson2009-09-161-0/+119
| | | | | (up to 3.1 times faster in tests), by special-casing base 10 in _PyLong_Format. (Backport of r74851 from py3k.)
* Fix potential signed-overflow bug in _PyLong_Format; also fixMark Dickinson2009-09-131-9/+11
| | | | a couple of whitespace issues.
* Remove redundant assignmentMark Dickinson2009-09-061-1/+0
|
* Remove unnecessary use of context for long getters.Mark Dickinson2009-05-021-10/+15
| | | | (Related to issue #5880).
* Issue #3166: Make long -> float (and int -> float) conversionsMark Dickinson2009-04-201-15/+152
| | | | | | correctly rounded, using round-half-to-even. This ensures that the value of float(n) doesn't depend on whether we're using 15-bit digits or 30-bit digits for Python longs.
* sys.long_info attributes should be ints, not longsMark Dickinson2009-04-021-2/+4
|
* Issue #5512: speed up the long division algorithm for Python longs.Mark Dickinson2009-03-231-94/+152
| | | | | | | | | | | | | | | The basic algorithm remains the same; the most significant speedups come from the following three changes: (1) normalize by shifting instead of multiplying and dividing (2) the old algorithm usually did an unnecessary extra iteration of the outer loop; remove this. As a special case, this means that long divisions with a single-digit result run twice as fast as before. (3) make inner loop much tighter. Various benchmarks show speedups of between 50% and 150% for long integer divisions and modulo operations.
* Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.Mark Dickinson2009-03-201-0/+49
| | | | Backport of r70459.
* Replace long with twodigits, to avoid dependingMark Dickinson2009-02-251-1/+1
| | | | on sizeof(digit) < sizeof(long)
* A few more minor fixes in longobject.cMark Dickinson2009-02-151-5/+4
|
* Issue #5260: Various portability and standards compliance fixes, optimizationsMark Dickinson2009-02-151-46/+35
| | | | | | | and cleanups in Objects/longobject.c. The most significant change is that longs now use less memory: average savings are 2 bytes per long on 32-bit systems and 6 bytes per long on 64-bit systems. (This memory saving already exists in py3k.)
* Issue #5175: PyLong_AsUnsignedLongLong now raises OverflowError forMark Dickinson2009-02-101-1/+1
| | | | | | negative arguments. Previously, it raised TypeError. Thanks Lisandro Dalcin.
* Fix comment.Mark Dickinson2009-01-261-3/+3
|
* Fix undefined behaviour (left shift of negative value) in long_hash. Also,Mark Dickinson2009-01-261-9/+10
| | | | rewrap a line of length > 79, and update comments.
* No need for carry to be type twodigits in _PyLong_AsByteArray; digit is ↵Mark Dickinson2009-01-251-1/+1
| | | | | | large enough. This change should silence a compiler warning on Windows.
* Issue #4393: fix 3 classes of potential portability problems in longobject.c:Mark Dickinson2009-01-241-23/+20
| | | | | | | - fix some places where counters into ob_digit were declared as int instead of Py_ssize_t - add (twodigit) casts where necessary - fix code in _PyLong_AsByteArray that uses << on negative values
* Issue #3439: add bit_length method to int and long.Mark Dickinson2008-12-171-0/+71
| | | | | Thanks Fredrik Johansson and Victor Stinner for code, Raymond Hettinger for review.
* Issue #1481296: (again!) Make conversion of a float NaN to an int orMark Dickinson2008-08-041-2/+4
| | | | | | | long raise ValueError instead of returning 0. Also, change the error message for conversion of an infinity to an integer, replacing 'long' by 'integer', so that it's appropriate for both long(float('inf')) and int(float('inf')).
* Security patches from Apple: prevent int overflow when allocating memoryNeal Norwitz2008-07-311-0/+2
|
* Added additional __sizeof__ implementations and addressed comments made inRobert Schuppenies2008-07-101-2/+2
| | | | Issue3122.
* Revert 64424, 64438, and 64439.Raymond Hettinger2008-06-241-7/+0
|
* Make bin() implementation parallel oct() and hex() so that int/long ↵Raymond Hettinger2008-06-201-0/+7
| | | | subclasses can override or so that other classes can support.
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-16/+16
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* Some style nits. Also clarify in the docstrings what __sizeof__ does.Georg Brandl2008-06-011-1/+1
|
* Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.Robert Schuppenies2008-06-011-0/+13
|
* Refactor and clean up str.format() code (and helpers) in advance of ↵Eric Smith2008-05-301-16/+11
| | | | optimizations.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-17/+17
|
* I finally got the time to update and merge Mark's and my trunk-math branch. ↵Christian Heimes2008-04-181-0/+12
| | | | | | The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math. The patch also adds acosh, asinh, atanh, log1p and copysign to all platforms. Finally it fixes differences between platforms like different results or exceptions for edge cases. Have fun :)
* Fix for possible signed overflow: the behaviour of -LONG_MIN isMark Dickinson2008-04-151-6/+19
| | | | undefined in ANSI C.
* Revert r61969 which added casts to Py_CHARMASK to avoid compiler warnings.Neal Norwitz2008-03-281-5/+5
| | | | | | Rather than sprinkle casts throughout the code, change Py_CHARMASK to always cast it's result to an unsigned char. This should ensure we do the right thing when accessing an array with the result.