summaryrefslogtreecommitdiffstats
path: root/Objects/complexobject.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35059: PyObject_INIT() casts to PyObject* (GH-10674)Victor Stinner2018-11-231-1/+1
| | | | | | PyObject_INIT() and PyObject_INIT_VAR() now cast their first argument to PyObject*, as done in Python 3.7. Revert partially commit b4435e20a92af474f117b78b98ddc6f515363af5.
* bpo-35059: Convert PyObject_INIT() to function (GH-10077)Victor Stinner2018-10-261-1/+1
| | | | | * Convert PyObject_INIT() and PyObject_INIT_VAR() macros to static inline functions. * Fix usage of these functions: cast to PyObject* or PyVarObject*.
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-2/+2
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-31979: Simplify transforming decimals to ASCII (#4336)Serhiy Storchaka2017-11-131-4/+3
| | | | | in int(), float() and complex() parsers. This also speeds up parsing non-ASCII numbers by around 20%.
* Add the const qualifier to "char *" variables that refer to literal strings. ↵Serhiy Storchaka2017-11-111-3/+3
| | | | (#4370)
* Update Argument Clinic generated code for bpo-29878. (#1001)Serhiy Storchaka2017-04-051-1/+1
|
* bpo-29878: Add global instances of int for 0 and 1. (#852)Serhiy Storchaka2017-03-301-1/+1
|
* bpo-29894: Deprecate returning an instance of complex subclass from ↵Serhiy Storchaka2017-03-241-10/+19
| | | | | __complex__. (#798) In a future versions of Python this can be an error.
* bpo-29793: Convert some builtin types constructors to Argument Clinic. (#615)Serhiy Storchaka2017-03-191-17/+23
|
* bpo-29602: fix signed zero handling in complex constructor. (#203)Mark Dickinson2017-02-201-3/+3
| | | | | | * Fix incorrect handling of signed zeros for complex-related classes. * Add Misc/NEWS entry.
* Use _PyObject_CallNoArg()Victor Stinner2016-12-061-1/+1
| | | | | | | Replace: PyObject_CallFunctionObjArgs(callable, NULL) with: _PyObject_CallNoArg(callable)
* Backed out changeset b9c9691c72c5Victor Stinner2016-12-041-1/+1
| | | | | | Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
* Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner2016-12-011-1/+1
| | | | | | | | | | | | | | * PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507.
* Issue #28203: Merge from 3.5Mark Dickinson2016-09-241-6/+17
|\
| * Issue #28203: Fix incorrect type in error message from complex(1.0, {2:3}). ↵Mark Dickinson2016-09-241-6/+17
| | | | | | | | Patch by Soumya Sharma.
* | Issue #26331: Implement the parsing part of PEP 515.Brett Cannon2016-09-091-26/+37
|/ | | | Thanks to Georg Brandl for the patch.
* Issue #24802: Merge null termination fixes from 3.4 into 3.5Martin Panter2015-11-071-7/+0
|\
| * Issue #24802: Copy bytes-like objects to null-terminated buffers if necessaryMartin Panter2015-11-071-7/+0
| | | | | | | | | | | | | | | | This avoids possible buffer overreads when int(), float(), compile(), exec() and eval() are passed bytes-like objects. Similar code is removed from the complex() constructor, where it was not reachable. Patch by John Leitch, Serhiy Storchaka and Martin Panter.
* | Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()Serhiy Storchaka2015-02-021-1/+8
|\ \ | |/ | | | | and PyObject_AsWriteBuffer().
| * Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()Serhiy Storchaka2015-02-021-1/+8
| | | | | | | | and PyObject_AsWriteBuffer().
* | Issue #22604: Fix assertion error in debug mode when dividing a complex ↵Antoine Pitrou2014-10-101-2/+6
|\ \ | |/ | | | | number by (nan+0j).
| * Issue #22604: Fix assertion error in debug mode when dividing a complex ↵Antoine Pitrou2014-10-101-2/+6
| | | | | | | | number by (nan+0j).
* | Issue #21803: remove macro indirections in complexobject.hAntoine Pitrou2014-07-071-17/+17
|/
* 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.
* #17080: improve error message of float/complex when the wrong type is passed.Ezio Melotti2013-11-071-4/+6
|
* #19068: merge with 3.3.Ezio Melotti2013-10-051-2/+2
|\
| * #19068: use imperative mood in complex object docstrings. Patch by Marco Buttu.Ezio Melotti2013-10-051-2/+2
| |
* | Issue #18722: Remove uses of the "register" keyword in C code.Antoine Pitrou2013-08-131-1/+1
| |
* | 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 #16290: __complex__ must now always return an instance of complex.Mark Dickinson2012-11-141-6/+6
|/
* Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args ↵Victor Stinner2012-05-291-3/+14
| | | | | | | | | | | | | | | | | and str.format(args) * Formatting string, int, float and complex use the _PyUnicodeWriter API. It avoids a temporary buffer in most cases. * Add _PyUnicodeWriter_WriteStr() to restore the PyAccu optimization: just keep a reference to the string if the output is only composed of one string * Disable overallocation when formatting the last argument of str%args and str.format(args) * Overallocation allocates at least 100 characters: add min_length attribute to the _PyUnicodeWriter structure * Add new private functions: _PyUnicode_FastCopyCharacters(), _PyUnicode_FastFill() and _PyUnicode_FromASCII() The speed up is around 20% in average.
* use the static identifier api for looking up special methodsBenjamin Peterson2012-01-221-2/+2
| | | | | I had to move the static identifier code from unicodeobject.h to object.h in order for this to work.
* Implement PEP 393.Martin v. Löwis2011-09-281-15/+4
|
* Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.Brian Curtin2011-08-111-2/+1
| | | | The macro was introduced in #12724.
* Issue #10833: Use PyErr_Format() and PyUnicode_FromFormat() instead ofVictor Stinner2011-03-211-13/+1
| | | | | PyOS_snprintf() to avoid temporary buffer allocated on the stack and a conversion from bytes to Unicode.
* Removed static function complex_format, moved it into complex_repr. Modified ↵Eric Smith2010-12-041-10/+8
| | | | tests to check both str and repr, which are the same for complex.
* Issue #10557: Fixed error messages from float() and other numericAlexander Belopolsky2010-12-041-13/+17
| | | | | | types. Added a new API function, PyUnicode_TransformDecimalToASCII(), which transforms non-ASCII decimal digits in a Unicode string to their ASCII equivalents.
* #6780: fix complex() constructor TypeError messageVictor Stinner2010-12-031-1/+1
|
* follow up to #9778: define and use an unsigned hash typeBenjamin Peterson2010-10-231-7/+7
|
* make hashes always the size of pointers; introduce Py_hash_t #9778Benjamin Peterson2010-10-171-2/+2
|
* Issue #9337: Make float.__str__ identical to float.__repr__.Mark Dickinson2010-08-041-7/+1
| | | | (And similarly for complex numbers.)
* Issue #8188: Introduce a new scheme for computing hashes of numbersMark Dickinson2010-05-231-9/+9
| | | | | | (instances of int, float, complex, decimal.Decimal and fractions.Fraction) that makes it easy to maintain the invariant that hash(x) == hash(y) whenever x and y have equal value.
* Issue #8748: Fix two issues with comparisons between complex and integerMark Dickinson2010-05-211-8/+44
| | | | | | | | | | objects. (1) The comparison could incorrectly return True in some cases (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality. (2) The comparison raised an OverflowError for large integers, leading to unpredictable exceptions when combining integers and complex objects in sets or dicts. Patch by Meador Inge.
* Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-806/+806
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* Issue #7845: Make 1j.__le__(2j) return NotImplemented rather than raising ↵Mark Dickinson2010-03-131-4/+2
| | | | TypeError.
* Merged revisions 78319 via svnmerge fromEzio Melotti2010-02-221-1/+1
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r78319 | ezio.melotti | 2010-02-22 18:30:58 +0200 (Mon, 22 Feb 2010) | 1 line #7482: clarify error message in case of division by zero of float and complex numbers. ........
* Merged revisions 77292-77293 via svnmerge fromBenjamin Peterson2010-01-041-36/+26
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r77292 | benjamin.peterson | 2010-01-03 18:43:01 -0600 (Sun, 03 Jan 2010) | 1 line do correct lookup of the __complex__ method ........ r77293 | benjamin.peterson | 2010-01-03 19:00:47 -0600 (Sun, 03 Jan 2010) | 1 line factor out __complex__ lookup code to fix another case ........
* Merged revisions 76561 via svnmerge fromMark Dickinson2009-11-281-4/+0
| | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76561 | mark.dickinson | 2009-11-28 12:30:36 +0000 (Sat, 28 Nov 2009) | 5 lines Include ieeefp.h (when available) in pyport.h instead of individually in Objects/floatobject.c and Objects/complexobject.c. This should silence compiler warnings about implicit declaration of the 'finite' function on Solaris. ........
* Make sure memory is freed on error in complex_subtype_from_string.Mark Dickinson2009-10-261-8/+7
|
* Remove length limitation on string arguments to complex()Mark Dickinson2009-10-261-7/+11
|