summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Fix warnings about using char as an array subscript. This is not portableNeal Norwitz2008-03-271-5/+5
| | | | since char is signed on some platforms and unsigned on others.
* Fix build on platforms that don't have intptr_t. Patch by Joseph Armbruster.Jeffrey Yasskin2008-03-181-1/+1
|
* Finished backporting PEP 3127, Integer Literal Support and Syntax.Eric Smith2008-03-171-1/+14
| | | | | | | | Added 0b and 0o literals to tokenizer. Modified PyOS_strtoul to support 0b and 0o inputs. Modified PyLong_FromString to support guessing 0b and 0o inputs. Renamed test_hexoct.py to test_int_literal.py and added binary tests. Added upper and lower case 0b, 0O, and 0X tests to test_int_literal.py
* Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith2008-02-171-0/+36
| | | | | | | | | | | | | | | Highlights: - Adding PyObject_Format. - Adding string.Format class. - Adding __format__ for str, unicode, int, long, float, datetime. - Adding builtin format. - Adding ''.format and u''.format. - str/unicode fixups for formatters. The files in Objects/stringlib that implement PEP 3101 (stringdefs.h, unicodedefs.h, formatter.h, string_format.h) are identical in trunk and py3k. Any changes from here on should be made to trunk, and changes will propogate to py3k).
* Added PyNumber_ToBase and supporting routines _PyInt_Format andEric Smith2008-02-101-14/+23
| | | | | | | | | | | | | | | | | _PyLong_Format. In longobject.c, changed long_format to _PyLong_Format. In intobject.c, changed uses of PyOS_snprintf to _PyInt_Format instead. _PyLong_Format is similar to py3k's routine of the same name, except it has 2 additional parameters: addL and newstyle. addL was existing in long_format, and controls adding the trailing "L". This is unneeded in py3k. newstyle is used to control whether octal prepends "0" (the pre-2.6 style), or "0o" (the 3.0 sytle). PyNumber_ToBase is needed for PEP 3127 (Integer Literal Support and Syntax) and PEP 3101 (Advanced String Formatting). This changeset does not need merging into py3k.
* Backport of several functions from Python 3.0 to 2.6 including ↵Christian Heimes2008-01-251-165/+165
| | | | | | | PyUnicode_FromString, PyUnicode_Format and PyLong_From/AsSsize_t. The functions are partly required for the backport of the bytearray type and _fileio module. They should also make it easier to port C to 3.0. First chapter of the Python 3.0 io framework back port: _fileio The next step depends on a working bytearray type which itself depends on a backport of the nwe buffer API.