summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Issue #27073: Removed redundant checks in long_add and long_sub.Serhiy Storchaka2016-06-031-2/+10
| | | | Patch by Oren Milman.
* Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.Serhiy Storchaka2016-05-121-21/+3
|\
| * Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses.Serhiy Storchaka2016-05-121-21/+3
| |
* | longobject.c: fix compilation warning on Windows 64-bitVictor Stinner2016-03-231-1/+1
| | | | | | | | We know that Py_SIZE(b) is -1 or 1 an so fits into the sdigit type.
* | Issues #26289 and #26315: Optimize floor/modulo div for single-digit longsYury Selivanov2016-02-111-0/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Microbenchmarks show 2-2.5x improvement. Built-in 'divmod' function is now also ~10% faster. -m timeit -s "x=22331" "x//2;x//-3;x//4;x//5;x//-6;x//7;x//8;x//-99;x//100;" with patch: 0.321 without patch: 0.633 -m timeit -s "x=22331" "x%2;x%3;x%-4;x%5;x%6;x%-7;x%8;x%99;x%-100;" with patch: 0.224 without patch: 0.66 Big thanks to Serhiy Storchaka, Mark Dickinson and Victor Stinner for thorow code reviews and algorithms improvements.
* | Issue #26288: Fix commentYury Selivanov2016-02-061-3/+3
| |
* | Issue #26288: Optimize PyLong_AsDouble.Yury Selivanov2016-02-061-0/+7
| |
* | Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-1/+1
|\ \ | |/ | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
| * Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-1/+1
| |\ | | | | | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
| | * Issue #24731: Fixed crash on converting objects with special methodsSerhiy Storchaka2015-11-251-1/+1
| | | | | | | | | | | | | | | __bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
* | | Fix compiler warnings (uninitialized variables), false alarms in factVictor Stinner2015-10-141-4/+2
| | |
* | | Fix long_format_binary()Victor Stinner2015-10-141-1/+1
| | | | | | | | | | | | Issue #25399: Fix long_format_binary(), allocate bytes for the bytes writer.
* | | Issue #25349: Optimize bytes % intVictor Stinner2015-10-091-27/+93
|/ / | | | | | | | | | | | | | | Optimize bytes.__mod__(args) for integere formats: %d (%i, %u), %o, %x and %X. _PyBytesWriter is now used to format directly the integer into the writer buffer, instead of using a temporary bytes object. Formatting is between 30% and 50% faster on a microbenchmark.
* | Issue #24999: In longobject.c, use two shifts instead of ">> 2*PyLong_SHIFT" toVictor Stinner2015-09-191-4/+6
| | | | | | | | | | | | avoid undefined behaviour when LONG_MAX type is smaller than 60 bits. This change should fix a warning with the ICC compiler.
* | Issue #22486: Added the math.gcd() function. The fractions.gcd() function ↵Serhiy Storchaka2015-05-121-0/+205
| | | | | | | | | | | | now is deprecated. Based on patch by Mark Dickinson.
* | #16518: Bring error messages in harmony with docs ("bytes-like object")R David Murray2014-10-051-3/+1
| | | | | | | | | | | | | | | | | | | | Some time ago we changed the docs to consistently use the term 'bytes-like object' in all the contexts where bytes, bytearray, memoryview, etc are used. This patch (by Ezio Melotti) completes that work by changing the error messages that previously reported that certain types did "not support the buffer interface" to instead say that a bytes-like object is required. (The glossary entry for bytes-like object references the discussion of the buffer protocol in the docs.)
* | Removed redundant casts to `char *`.Serhiy Storchaka2014-09-281-1/+1
| | | | | | | | Corresponding functions now accept `const char *` (issue #1772673).
* | Issue #22156: Fix "comparison between signed and unsigned integers" compilerVictor Stinner2014-08-151-2/+2
| | | | | | | | | | | | | | warnings in the Objects/ subdirectory. PyType_FromSpecWithBases() and PyType_FromSpec() now reject explicitly negative slot identifiers.
* | Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()Victor Stinner2014-05-141-37/+36
| | | | | | | | | | Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between pyconfig.h and pymacros.h.
* | Issue #21193: Make (e.g.,) pow(2, -3, 5) raise ValueError rather than ↵Mark Dickinson2014-04-111-1/+1
|/ | | | TypeError. Patch by Josh Rosenberg.
* merge 3.3Benjamin Peterson2014-03-151-1/+2
|\
| * fix c89 declaration orderBenjamin Peterson2014-03-151-1/+2
| |
* | merge 3.3Benjamin Peterson2014-03-151-1/+2
|\ \ | |/
| * don't do pointer arithmetic with signed numbersBenjamin Peterson2014-03-151-1/+2
| |
| * Issue #17576: Removed deprecation warnings added in changeset 618cca51a27e.Serhiy Storchaka2013-12-141-9/+0
| |
* | Issue #17576: Deprecation warning emitted now when __int__() or __index__()Serhiy Storchaka2013-12-111-104/+111
|\ \ | |/ | | | | | | return not int instance. Introduced _PyLong_FromNbInt() and refactored PyLong_As*() functions.
| * Issue #17576: Deprecation warning emitted now when __int__() or __index__()Serhiy Storchaka2013-12-111-104/+111
| | | | | | | | | | return not int instance. Introduced _PyLong_FromNbInt() and refactored PyLong_As*() functions.
* | Silence expression result unused warnings with clang.Christian Heimes2013-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The PyObject_INIT() macros returns obj: ../cpython/Objects/methodobject.c:32:23: warning: expression result unused [-Wunused-value] PyObject_INIT(op, &PyCFunction_Type); ^~ ../cpython/Include/objimpl.h:139:69: note: expanded from macro 'PyObject_INIT' ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ^ 1 warning generated.
* | Issue #1772673: The type of `char*` arguments now changed to `const char*`.Serhiy Storchaka2013-10-191-8/+8
| |
* | 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. Merged from 3.3.
| * 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.
* | Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka2013-08-271-50/+50
|\ \ | |/ | | | | error messages and comments.
| * Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka2013-08-271-50/+50
| | | | | | | | error messages and comments.
* | Issue #18722: Remove uses of the "register" keyword in C code.Antoine Pitrou2013-08-131-12/+12
| |
* | Issue #16741: Fix an error reporting in int().Serhiy Storchaka2013-08-031-28/+59
|\ \ | |/
| * Issue #16741: Fix an error reporting in int().Serhiy Storchaka2013-08-031-27/+62
| |
* | Minor consistency fixes for some longobject.c exception messages:Mark Dickinson2013-08-031-4/+4
| | | | | | | | | | | | - replace 'long int' / 'long' by 'int' - fix capitalization of "Python" in PyLong_AsUnsignedLong - "is too large" -> "too large", for consistency with other messages.
* | Issue #18520: Add a new PyStructSequence_InitType2() function, same thanVictor Stinner2013-07-221-2/+4
| | | | | | | | | | | | | | | | PyStructSequence_InitType() except that it has a return value (0 on success, -1 on error). * PyStructSequence_InitType2() now raises MemoryError on memory allocation failure * Fix also some calls to PyDict_SetItemString(): handle error
* | longobject.c: add an assertion to ensure that MEDIUM_VALUE() is only called onVictor Stinner2013-07-171-1/+2
| | | | | | | | small integers (0 or 1 digit)
* | Issue #18408: Rewrite NEGATE() macro in longobject.c to handle ↵Victor Stinner2013-07-171-24/+51
| | | | | | | | PyLong_FromLong() failure
* | Reuse Py_MIN and Py_MAX macros: remove duplicate MIN/MAX macrosVictor Stinner2013-06-041-9/+4
| | | | | | | | multiprocessing.h: remove unused MIN and MAX macros
* | Close #17694: Add minimum length to _PyUnicodeWriterVictor Stinner2013-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * Add also min_char attribute to _PyUnicodeWriter structure (currently unused) * _PyUnicodeWriter_Init() has no more argument (except the writer itself): min_length and overallocate must be set explicitly * In error handlers, only enable overallocation if the replacement string is longer than 1 character * CJK decoders don't use overallocation anymore * Set min_length, instead of preallocating memory using _PyUnicodeWriter_Prepare(), in many decoders * _PyUnicode_DecodeUnicodeInternal() checks for integer overflow
* | Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou2013-02-091-2/+2
|\ \ | |/ | | | | | | | | | | | | in the interpreter. I've left a couple of them in: zlib (third-party lib), getaddrinfo.c (doesn't include Python.h, and probably obsolete), _sre.c (legitimate use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
| * Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou2013-02-091-2/+2
| |\ | | | | | | | | | | | | | | | | | | | | | in the interpreter. I've left a couple of them in: zlib (third-party lib), getaddrinfo.c (doesn't include Python.h, and probably obsolete), _sre.c (legitimate use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
| | * Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou2013-02-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | in the interpreter. I've left a couple of them in: zlib (third-party lib), getaddrinfo.c (doesn't include Python.h, and probably obsolete), _sre.c (legitimate use for the re.LOCALE flag).
| * | Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-191-0/+18
| |\ \ | | |/ | | | | | | | | | | | | when result of PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
| | * Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-191-0/+18
| | | | | | | | | | | | | | | | | | when result of PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
* | | Issue #16772: in int(x, base), non-integer bases must have an __index__ method.Mark Dickinson2013-01-271-5/+0
| | |
* | | Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-141-0/+18
| | | | | | | | | | | | when result of PyLong_AsLong() narrowed to int without checks.
* | | Issue #16761: Raise TypeError when int() called with base argument only.Serhiy Storchaka2012-12-281-3/+9
|\ \ \ | |/ /