summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove out-of-date comment about making ints and longs hash equal.Mark Dickinson2010-03-191-3/+0
|
* Issue #8014: Fix PyLong_As<c-integer-type> methods not to produce anMark Dickinson2010-03-131-5/+20
| | | | | internal error on non-integer input: they now raise TypeError instead. This is needed for attributes declared via PyMemberDefs.
* Move docstrings for long.to_bytes and long.from_bytes after the ↵Mark Dickinson2010-01-301-27/+27
| | | | corresponding functions.
* Merged revisions 77842 via svnmerge fromMark Dickinson2010-01-301-0/+96
| | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r77842 | mark.dickinson | 2010-01-30 10:08:33 +0000 (Sat, 30 Jan 2010) | 4 lines Issue #7767: Add new C-API function PyLong_AsLongLongAndOverflow, a long long variant of PyLong_AsLongAndOverflow. Patch by Case Van Horsen. ........
* simplify string comparison of from_bytes/to_bytesBenjamin Peterson2010-01-091-20/+6
|
* Issue #1023290: Added API for the conversion of longs to bytes and vice-versa.Alexandre Vassalotti2010-01-091-0/+199
|
* Merged revisions 77234 via svnmerge fromMark Dickinson2010-01-021-221/+146
| | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r77234 | mark.dickinson | 2010-01-02 14:45:40 +0000 (Sat, 02 Jan 2010) | 7 lines Refactor some longobject internals: PyLong_AsDouble and _PyLong_AsScaledDouble (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. ........
* Merged revisions 77062 via svnmerge fromMark Dickinson2009-12-271-30/+250
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r77062 | mark.dickinson | 2009-12-27 14:55:57 +0000 (Sun, 27 Dec 2009) | 2 lines Issue #1811: Improve accuracy and consistency of true division for integers. ........
* Keep PyLong_AsLongAndOverflow documentation and implementation in syncMark Dickinson2009-12-211-9/+10
| | | | | between py3k and trunk; merge new tests from trunk to py3k. (See issue #7528.)
* Fix error message, for consistency with messages for % and //, and for ↵Mark Dickinson2009-12-071-1/+1
| | | | consistency with trunk
* Merge in the new GIL.Antoine Pitrou2009-11-101-4/+1
|
* Merged revisions 75697 via svnmerge fromMark Dickinson2009-10-251-66/+100
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r75697 | mark.dickinson | 2009-10-25 20:39:06 +0000 (Sun, 25 Oct 2009) | 3 lines Issue #1087418: Small performance boost for bitwise operations on longs. Initial patch by Gregory Smith; some tweaks added. ........
* Merged revisions 75110 via svnmerge fromMark Dickinson2009-09-281-7/+7
| | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r75110 | mark.dickinson | 2009-09-28 17:52:40 +0100 (Mon, 28 Sep 2009) | 9 lines Style/consistency/nano-optimization nit: replace occurrences of (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 compiler warningMark Dickinson2009-09-241-1/+2
|
* Merged revisions 75003 via svnmerge fromMark Dickinson2009-09-211-2/+3
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r75003 | mark.dickinson | 2009-09-21 17:16:44 +0100 (Mon, 21 Sep 2009) | 1 line Silence MSVC compiler warnings. ........
* Issue #6713 (continued): remove unused arbitrary-base conversion codeMark Dickinson2009-09-181-99/+34
| | | | from _PyLong_Format.
* Revert accidental changes to Objects/longobject.cMark Dickinson2009-09-171-44/+104
|
* Add some more module maintainers.Mark Dickinson2009-09-171-104/+44
|
* Bypass long_repr and _PyLong_Format for str(n), repr(n)Mark Dickinson2009-09-171-8/+2
|
* Issue #6713: Improve performance of str(n) and repr(n) for integers nMark Dickinson2009-09-161-0/+116
| | | | | (up to 3.1 times faster in tests), by special-casing base 10 in _PyLong_Format.
* Merged revisions 74769 via svnmerge fromMark Dickinson2009-09-131-7/+10
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74769 | mark.dickinson | 2009-09-13 12:56:13 +0100 (Sun, 13 Sep 2009) | 3 lines Fix potential signed-overflow bug in _PyLong_Format; also fix a couple of whitespace issues. ........
* Merged revisions 74689 via svnmerge fromMark Dickinson2009-09-061-1/+0
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74689 | mark.dickinson | 2009-09-06 21:51:37 +0100 (Sun, 06 Sep 2009) | 1 line Remove redundant assignment ........
* Merged revisions 72202 via svnmerge fromMark Dickinson2009-05-021-10/+15
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r72202 | mark.dickinson | 2009-05-02 18:55:01 +0100 (Sat, 02 May 2009) | 3 lines Remove unnecessary use of context for long getters. (Related to issue #5880). ........
* Typo fix. Thanks Damien Diederen.Mark Dickinson2009-04-271-1/+1
|
* Merged revisions 71772 via svnmerge fromMark Dickinson2009-04-201-15/+152
| | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r71772 | mark.dickinson | 2009-04-20 22:13:33 +0100 (Mon, 20 Apr 2009) | 5 lines Issue #3166: Make long -> float (and int -> float) conversions 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. ........
* Rewrap some long lines.Mark Dickinson2009-04-021-2/+4
|
* Merged revisions 70542 via svnmerge fromMark Dickinson2009-03-231-94/+152
| | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r70542 | mark.dickinson | 2009-03-23 18:25:13 +0000 (Mon, 23 Mar 2009) | 14 lines Issue #5512: speed up the long division algorithm for Python longs. 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: Make it possible to use 30-bit digits for PyLongs:Mark Dickinson2009-03-181-3/+59
| | | | | | | - new configure option --enable-big-digits - new structseq sys.int_info giving information about the internal format By default, 30-bit digits are enabled on 64-bit machines but disabled on 32-bit machines.
* Merged revisions 69974 via svnmerge fromMark Dickinson2009-02-251-1/+1
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r69974 | mark.dickinson | 2009-02-25 20:29:50 +0000 (Wed, 25 Feb 2009) | 3 lines Replace long with twodigits, to avoid depending on sizeof(digit) < sizeof(long) ........
* Fix more places in Objects/longobject.c where it's silently assumed thatMark Dickinson2009-02-151-5/+5
| | | | sizeof(digit) < sizeof(int).
* A few more type fixes for py3k that were missed in r69635Mark Dickinson2009-02-151-12/+13
|
* Merged revisions 69634 via svnmerge fromMark Dickinson2009-02-151-56/+45
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r69634 | mark.dickinson | 2009-02-15 10:13:41 +0000 (Sun, 15 Feb 2009) | 6 lines Issue #5260: Various portability and standards compliance fixes, optimizations 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.) ........
* Merged revisions 69498 via svnmerge fromMark Dickinson2009-02-101-1/+1
| | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r69498 | mark.dickinson | 2009-02-10 15:46:50 +0000 (Tue, 10 Feb 2009) | 6 lines Issue #5175: PyLong_AsUnsignedLongLong now raises OverflowError for negative arguments. Previously, it raised TypeError. Thanks Lisandro Dalcin. ........
* Issue #1717: rename tp_compare to tp_reserved. I'll change theMark Dickinson2009-02-021-1/+1
| | | | | type of tp_compare in a separate commit, for ease of reversion should things go wrong.
* Issue #4707: round(x, n) now returns an integer when x is an integer.Mark Dickinson2009-01-281-20/+128
| | | | Previously it returned a float.
* Merged revisions 68974-68975 via svnmerge fromMark Dickinson2009-01-261-8/+9
| | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68974 | mark.dickinson | 2009-01-26 21:36:30 +0000 (Mon, 26 Jan 2009) | 4 lines Fix undefined behaviour (left shift of negative value) in long_hash. Also, rewrap a line of length > 79, and update comments. ........ r68975 | mark.dickinson | 2009-01-26 21:40:08 +0000 (Mon, 26 Jan 2009) | 2 lines Fix comment. ........
* Merged revisions 68947 via svnmerge fromMark Dickinson2009-01-251-1/+1
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68947 | mark.dickinson | 2009-01-25 22:12:31 +0000 (Sun, 25 Jan 2009) | 3 lines No need for carry to be type twodigits in _PyLong_AsByteArray; digit is large enough. This change should silence a compiler warning on Windows. ........
* Merged revisions 68890 via svnmerge fromMark Dickinson2009-01-241-23/+20
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68890 | mark.dickinson | 2009-01-24 15:27:44 +0000 (Sat, 24 Jan 2009) | 6 lines Issue #4393: fix 3 classes of potential portability problems in longobject.c: - 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 ........
* Some minor cleanups in PyLong_FromLong:Mark Dickinson2009-01-241-12/+15
| | | | | | | | | - fast path wasn't being properly taken for negative ints; thanks Victor Stinner for pointing this out. - use Py_SAFE_DOWNCAST instead of direct casting to digit (it's safer, especially if we ever consider moving to 30-bit digits) - cleaner way to write negation
* Issue 4842, patch 2/2: int('3L') should be invalid in Python 3.x.Mark Dickinson2009-01-201-2/+0
|
* Issue #4910, patch 3/3: rename nb_long to nb_reservedMark Dickinson2009-01-171-1/+1
|
* Issue 4910, patch 2 of (probably) 3: pave the way for renaming ofMark Dickinson2009-01-151-1/+1
| | | | | | | | | nb_long: remove last remaining use of nb_long (in the struct module) from the core, set nb_long slots on all builtin and extension types to 0, and remove uses of __long__ in test_complex and test_binop. Reviewed by Benjamin Peterson.
* Reduce the size of the _PyLong_DigitValue table.Raymond Hettinger2009-01-091-3/+3
|
* Issue #3106: Speedup some comparisons. This also removes the last callAntoine Pitrou2008-12-201-4/+35
| | | | to Py_CmpToRich from the codebase (in longobject.c).
* Forward merge of r67822 to py3k: add bit_length method to int.Mark Dickinson2008-12-171-0/+71
|
* Issue 4497: silence compiler warnings on Windows.Mark Dickinson2008-12-051-4/+4
|
* Closes release blocker #3627.Neal Norwitz2008-08-241-0/+2
| | | | | | | | | | | | | Merged revisions 65335 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt) ........ r65335 | neal.norwitz | 2008-07-31 10:17:14 -0700 (Thu, 31 Jul 2008) | 1 line Security patches from Apple: prevent int overflow when allocating memory ........
* Merged revisions ↵Georg Brandl2008-08-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 65459,65472,65481,65518,65536,65581,65609,65637,65641,65644-65645 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r65459 | gregory.p.smith | 2008-08-04 00:13:29 +0000 (Mon, 04 Aug 2008) | 4 lines - Issue #1857: subprocess.Popen.poll gained an additional _deadstate keyword argument in python 2.5, this broke code that subclassed Popen to include its own poll method. Fixed my moving _deadstate to an _internal_poll method. ........ r65472 | andrew.kuchling | 2008-08-04 01:43:43 +0000 (Mon, 04 Aug 2008) | 3 lines Bug 3228: Explicitly supply the file mode to avoid creating executable files, and add corresponding tests. Possible 2.5 backport candidate ........ r65481 | gregory.p.smith | 2008-08-04 07:33:37 +0000 (Mon, 04 Aug 2008) | 22 lines Adds a sanity check to avoid a *very rare* infinite loop due to a corrupt tls key list data structure in the thread startup path. This change is a companion to r60148 which already successfully dealt with a similar issue on thread shutdown. In particular this loop has been observed happening from this call path: #0 in find_key () #1 in PyThread_set_key_value () #2 in _PyGILState_NoteThreadState () #3 in PyThreadState_New () #4 in t_bootstrap () #5 in pthread_start_thread () I don't know how this happens but it does, *very* rarely. On more than one hardware platform. I have not been able to reproduce it manually. (A flaky mutex implementation on the system in question is one hypothesis). As with r60148, the spinning we managed to observe in the wild was due to a single list element pointing back upon itself. ........ r65518 | mark.dickinson | 2008-08-04 21:30:09 +0000 (Mon, 04 Aug 2008) | 7 lines Issue #1481296: (again!) Make conversion of a float NaN to an int or 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')). ........ r65536 | andrew.kuchling | 2008-08-05 01:00:57 +0000 (Tue, 05 Aug 2008) | 1 line Bug 3228: take a test from Niels Gustaebel's patch, and based on his patch, check for having os.stat available ........ r65581 | guido.van.rossum | 2008-08-07 18:51:38 +0000 (Thu, 07 Aug 2008) | 3 lines Patch by Ian Charnas from issue 3517. Add F_FULLFSYNC if it exists (OS X only so far). ........ r65609 | antoine.pitrou | 2008-08-09 17:22:25 +0000 (Sat, 09 Aug 2008) | 3 lines #3205: bz2 iterator fails silently on MemoryError ........ r65637 | georg.brandl | 2008-08-11 09:07:59 +0000 (Mon, 11 Aug 2008) | 3 lines - Issue #3537: Fix an assertion failure when an empty but presized dict object was stored in the freelist. ........ r65641 | jesse.noller | 2008-08-11 14:28:07 +0000 (Mon, 11 Aug 2008) | 2 lines Remove the fqdn call for issue 3270 ........ r65644 | antoine.pitrou | 2008-08-11 17:21:36 +0000 (Mon, 11 Aug 2008) | 3 lines #3134: shutil referenced undefined WindowsError symbol ........ r65645 | jesse.noller | 2008-08-11 19:00:15 +0000 (Mon, 11 Aug 2008) | 2 lines Fix the connection refused error part of issue 3419, use errno module instead of a static list of possible connection refused messages. ........
* Optimization to stop creating new small longs and use theFacundo Batista2008-07-241-22/+28
| | | | one previously stored. Issue 2417.
* Merged revisions 64842,64853,64856,64945 via svnmerge fromRobert Schuppenies2008-07-141-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r64842 | robert.schuppenies | 2008-07-10 15:43:26 +0200 (Thu, 10 Jul 2008) | 2 lines Fixed Issue3122 and extended sys.getsizeof tests for built-in types. ........ r64853 | robert.schuppenies | 2008-07-10 17:24:04 +0200 (Thu, 10 Jul 2008) | 3 lines Added additional __sizeof__ implementations and addressed comments made in Issue3122. ........ r64856 | robert.schuppenies | 2008-07-10 19:13:55 +0200 (Thu, 10 Jul 2008) | 3 lines Added garbage collector overhead and optional default return value to sys.getsizeof. ........ r64945 | robert.schuppenies | 2008-07-14 10:42:18 +0200 (Mon, 14 Jul 2008) | 2 lines Fixed test failure on Win64 machines. ........