Commit Graph

410 Commits

Author SHA1 Message Date
Mark Dickinson 82cb124300 Issue #25221: merge from 3.5. 2016-09-10 20:20:08 +01:00
Mark Dickinson 36820dd5a9 Issue #25221: Fix corrupted result from PyLong_FromLong(0) when Python is compiled with NSMALLPOSINTS = 0. 2016-09-10 20:17:36 +01:00
Brett Cannon a721abac29 Issue #26331: Implement the parsing part of PEP 515.
Thanks to Georg Brandl for the patch.
2016-09-09 14:57:09 -07:00
Martin Panter 0be894b2f6 Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-09-07 12:03:06 +00:00
Benjamin Peterson 2f8bfef158 replace PY_SIZE_MAX with SIZE_MAX 2016-09-07 09:26:18 -07:00
Benjamin Peterson ca47063998 replace Py_(u)intptr_t with the c99 standard types 2016-09-06 13:47:26 -07:00
Benjamin Peterson d953f8e10b remove some silly defined() tests 2016-09-06 10:51:19 -07:00
Benjamin Peterson af580dff4a replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
Benjamin Peterson ed4aa83ff7 require a long long data type (closes #27961) 2016-09-05 17:44:18 -07:00
Raymond Hettinger 15f44ab043 Issue #27895: Spelling fixes (Contributed by Ville Skyttä). 2016-08-30 10:47:49 -07:00
Mark Dickinson 82a95277b8 Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory. 2016-08-29 19:27:06 +01:00
Mark Dickinson 4e1de16f88 Issue #25402: in int-to-decimal-string conversion, reduce intermediate storage requirements and relax restriction on converting large integers. Patch by Serhiy Storchaka. 2016-08-29 17:26:43 +01:00
Mark Dickinson 583c6e860c Issue #27214: Fix potential bug and remove useless optimization in long_invert. Thanks Oren Milman. 2016-08-29 16:40:29 +01:00
Mark Dickinson b820d7f631 Issue #27792: force int return type for modulo operations involving bools. 2016-08-22 12:24:46 +01:00
Mark Dickinson 1dc3c898a8 Untabify Objects/longobject.c. 2016-08-21 10:33:36 +01:00
Mark Dickinson dc590a4cc3 Issue #25604: Fix minor bug in integer true division, which could
have caused off-by-one-ulp results on certain platforms.
2016-08-21 10:23:23 +01:00
Victor Stinner 8bcf312d09 Issue #27786: Simplify x_sub()
The z variable is known to be a fresh number which cannot be shared, Py_SIZE()
can be used directly to negate the number.
2016-08-17 19:48:33 +02:00
Martin Panter 8bde911115 Issue #27626: Merge spelling fixes from 3.5 2016-07-28 01:30:58 +00:00
Martin Panter eb9957065a Issue #27626: Spelling fixes in docs, comments and internal names
Based on patch by Ville Skyttä.
2016-07-28 01:11:04 +00:00
Serhiy Storchaka e63e5d60ee Issue #27073: Removed redundant checks in long_add and long_sub.
Patch by Oren Milman.
2016-06-04 00:06:45 +03:00
Serhiy Storchaka ea36c941a1 Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses. 2016-05-12 10:37:58 +03:00
Serhiy Storchaka 1f364438ad Issue #23640: int.from_bytes() no longer bypasses constructors for subclasses. 2016-05-12 10:39:32 +03:00
Victor Stinner f963c13597 longobject.c: fix compilation warning on Windows 64-bit
We know that Py_SIZE(b) is -1 or 1 an so fits into the sdigit type.
2016-03-23 18:36:54 +01:00
Yury Selivanov e0b23095ee Issues #26289 and #26315: Optimize floor/modulo div for single-digit longs
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.
2016-02-11 10:26:27 -05:00
Yury Selivanov a0fcaca4e1 Issue #26288: Fix comment 2016-02-06 12:21:33 -05:00
Yury Selivanov 186c30b7ae Issue #26288: Optimize PyLong_AsDouble. 2016-02-05 19:40:01 -05:00
Serhiy Storchaka bb6e4a0b31 Issue #24731: Fixed crash on converting objects with special methods
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:53:19 +02:00
Serhiy Storchaka f9afda57ad Issue #24731: Fixed crash on converting objects with special methods
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:52:04 +02:00
Serhiy Storchaka 15095800a3 Issue #24731: Fixed crash on converting objects with special methods
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
2015-11-25 15:47:01 +02:00
Victor Stinner 1285e5c805 Fix compiler warnings (uninitialized variables), false alarms in fact 2015-10-14 12:10:20 +02:00
Victor Stinner 199c9a6f4b Fix long_format_binary()
Issue #25399: Fix long_format_binary(), allocate bytes for the bytes writer.
2015-10-14 09:47:23 +02:00
Victor Stinner be75b8cf23 Issue #25349: Optimize bytes % int
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.
2015-10-09 22:43:24 +02:00
Victor Stinner 5783fd2c58 Issue #24999: In longobject.c, use two shifts instead of ">> 2*PyLong_SHIFT" to
avoid undefined behaviour when LONG_MAX type is smaller than 60 bits.

This change should fix a warning with the ICC compiler.
2015-09-19 13:39:03 +02:00
Serhiy Storchaka 48e47aaa28 Issue #22486: Added the math.gcd() function. The fractions.gcd() function now is
deprecated.  Based on patch by Mark Dickinson.
2015-05-13 00:19:51 +03:00
R David Murray 861470c836 #16518: Bring error messages in harmony with docs ("bytes-like object")
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.)
2014-10-05 11:47:01 -04:00
Serhiy Storchaka 20b39b27d9 Removed redundant casts to `char *`.
Corresponding functions now accept `const char *` (issue #1772673).
2014-09-28 11:27:24 +03:00
Victor Stinner 12174a5dca Issue #22156: Fix "comparison between signed and unsigned integers" compiler
warnings in the Objects/ subdirectory.

PyType_FromSpecWithBases() and PyType_FromSpec() now reject explicitly negative
slot identifiers.
2014-08-15 23:17:38 +02:00
Victor Stinner 45e8e2f218 Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()
Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between
pyconfig.h and pymacros.h.
2014-05-14 17:24:35 +02:00
Mark Dickinson 0c346d827d Issue #21193: Make (e.g.,) pow(2, -3, 5) raise ValueError rather than TypeError. Patch by Josh Rosenberg. 2014-04-11 14:34:40 -04:00
Benjamin Peterson 1aca78da62 merge 3.3 2014-03-14 21:54:41 -05:00
Benjamin Peterson 45c9dceb56 fix c89 declaration order 2014-03-14 21:53:51 -05:00
Benjamin Peterson dfa822811a merge 3.3 2014-03-14 21:47:36 -05:00
Benjamin Peterson 041c38a790 don't do pointer arithmetic with signed numbers 2014-03-14 21:47:23 -05:00
Serhiy Storchaka c836a28cc1 Issue #17576: Removed deprecation warnings added in changeset 618cca51a27e. 2013-12-14 21:07:09 +02:00
Serhiy Storchaka c4f3212abc Issue #17576: Deprecation warning emitted now when __int__() or __index__()
return not int instance.  Introduced _PyLong_FromNbInt() and refactored
PyLong_As*() functions.
2013-12-11 21:26:36 +02:00
Serhiy Storchaka 31a655411a Issue #17576: Deprecation warning emitted now when __int__() or __index__()
return not int instance.  Introduced _PyLong_FromNbInt() and refactored
PyLong_As*() functions.
2013-12-11 21:07:54 +02:00
Christian Heimes d3afe781b1 Silence expression result unused warnings with clang.
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.
2013-12-04 09:27:47 +01:00
Serhiy Storchaka c679227e31 Issue #1772673: The type of `char*` arguments now changed to `const char*`. 2013-10-19 21:03:34 +03:00
Tim Peters 9259c21a63 Issue #19171: speed some cases of 3-argument long pow().
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.
2013-10-05 16:55:38 -05:00
Tim Peters 81a93159d7 Issue #19171: speed some cases of 3-argument long pow().
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.
2013-10-05 16:53:52 -05:00