summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for ↵Serhiy Storchaka2020-10-091-0/+11
| | | | "fildes". (GH-22620)
* bpo-41974: Remove complex.__float__, complex.__floordiv__, etc (GH-22593)Serhiy Storchaka2020-10-095-56/+19
| | | | | | Remove complex special methods __int__, __float__, __floordiv__, __mod__, __divmod__, __rfloordiv__, __rmod__ and __rdivmod__ which always raised a TypeError.
* Fix the attribute names in the docstring of GenericAlias (GH-22594)Mikhail Golubev2020-10-081-1/+1
|
* Revert "bpo-26680: Incorporate is_integer in all built-in and standard ↵Raymond Hettinger2020-10-072-33/+1
| | | | | library numeric types (GH-6121)" (GH-22584) This reverts commit 58a7da9e125422323f79c4ee95ac5549989d8162.
* Fix comment about PyObject_IsTrue. (GH-22343)Stefan Pochmann2020-10-071-1/+1
| | | The `for` statement doesn't use a condition and this function, the `while` statement does.
* bpo-41909: Enable previously disabled recursion checks. (GH-22536)Serhiy Storchaka2020-10-042-4/+0
| | | | | | | | | | | Enable recursion checks which were disabled when get __bases__ of non-type objects in issubclass() and isinstance() and when intern strings. It fixes a stack overflow when getting __bases__ leads to infinite recursion. Originally recursion checks was disabled for PyDict_GetItem() which silences all errors including the one raised in case of detected recursion and can return incorrect result. But now the code uses PyDict_GetItemWithError() and PyDict_SetDefault() instead.
* bpo-41922: Use PEP 590 vectorcall to speed up reversed() (GH-22523)Dong-hee Na2020-10-031-0/+19
|
* bpo-41692: Deprecate PyUnicode_InternImmortal() (GH-22486)Victor Stinner2020-10-021-0/+9
| | | | The PyUnicode_InternImmortal() function is now deprecated and will be removed in Python 3.12: use PyUnicode_InternInPlace() instead.
* bpo-26680: Incorporate is_integer in all built-in and standard library ↵Robert Smallshire2020-10-012-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | numeric types (GH-6121) * bpo-26680: Adds support for int.is_integer() for compatibility with float.is_integer(). The int.is_integer() method always returns True. * bpo-26680: Adds a test to ensure that False.is_integer() and True.is_integer() are always True. * bpo-26680: Adds Real.is_integer() with a trivial implementation using conversion to int. This default implementation is intended to reduce the workload for subclass implementers. It is not robust in the presence of infinities or NaNs and may have suboptimal performance for other types. * bpo-26680: Adds Rational.is_integer which returns True if the denominator is one. This implementation assumes the Rational is represented in it's lowest form, as required by the class docstring. * bpo-26680: Adds Integral.is_integer which always returns True. * bpo-26680: Adds tests for Fraction.is_integer called as an instance method. The tests for the Rational abstract base class use an unbound method to sidestep the inability to directly instantiate Rational. These tests check that everything works correct as an instance method. * bpo-26680: Updates documentation for Real.is_integer and built-ins int and float. The call x.is_integer() is now listed in the table of operations which apply to all numeric types except complex, with a reference to the full documentation for Real.is_integer(). Mention of is_integer() has been removed from the section 'Additional Methods on Float'. The documentation for Real.is_integer() describes its purpose, and mentions that it should be overridden for performance reasons, or to handle special values like NaN. * bpo-26680: Adds Decimal.is_integer to the Python and C implementations. The C implementation of Decimal already implements and uses mpd_isinteger internally, we just expose the existing function to Python. The Python implementation uses internal conversion to integer using to_integral_value(). In both cases, the corresponding context methods are also implemented. Tests and documentation are included. * bpo-26680: Updates the ACKS file. * bpo-26680: NEWS entries for int, the numeric ABCs and Decimal. Co-authored-by: Robert Smallshire <rob@sixty-north.com>
* bpo-41870: Avoid the test when nargs=0 (GH-22462)Dong-hee Na2020-10-011-3/+3
|
* bpo-41873: Add vectorcall for float() (GH-22432)Dennis Sweeney2020-09-291-0/+19
|
* bpo-41870: Use PEP 590 vectorcall to speed up bool() (GH-22427)Dong-hee Na2020-09-281-0/+25
| | | | | * bpo-41870: Use PEP 590 vectorcall to speed up bool() * bpo-41870: Add NEWS.d
* bpo-41428: Fix compiler warning in unionobject.c (GH-22416)Victor Stinner2020-09-261-3/+3
| | | | | | | Use Py_ssize_t type rather than int, to store lengths in unionobject.c. Fix the warning: Objects\unionobject.c(205,1): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data
* bpo-41428: Fix compiler warnings in unionobject.c (GH-22388)Victor Stinner2020-09-231-3/+3
| | | | | | | | | | | | | | | | Use Py_ssize_t type rather than int, to store lengths in unionobject.c. Fix warnings: Objects\unionobject.c(189,71): warning C4244: '+=': conversion from 'Py_ssize_t' to 'int', possible loss of data Objects\unionobject.c(182,1): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data Objects\unionobject.c(205,1): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data Objects\unionobject.c(437,1): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data
* bpo-41654: Fix compiler warning in MemoryError_dealloc() (GH-22387)Victor Stinner2020-09-231-1/+2
| | | | | | Fix warning: Objects\exceptions.c(2324,56): warning C4098: 'MemoryError_dealloc': 'void' function returning a value
* bpo-40170: Use inline _PyType_HasFeature() function (GH-22375)Victor Stinner2020-09-231-1/+1
| | | | | Use _PyType_HasFeature() in the _io module and in structseq implementation. Replace PyType_HasFeature() opaque function call with _PyType_HasFeature() inlined function.
* bpo-40521: Fix PyUnicode_InternInPlace() (GH-22376)Victor Stinner2020-09-231-0/+4
| | | | | Fix PyUnicode_InternInPlace() when the INTERNED_STRINGS macro is not defined (when the EXPERIMENTAL_ISOLATED_SUBINTERPRETERS macro is defined).
* bpo-41756: Refactor gen_send_ex(). (GH-22330)Serhiy Storchaka2020-09-221-94/+99
|
* bpo-41756: Introduce PyGen_Send C API (GH-22196)Vladimir Matveev2020-09-191-17/+48
| | | | | | | | | | | | | The new API allows to efficiently send values into native generators and coroutines avoiding use of StopIteration exceptions to signal returns. ceval loop now uses this method instead of the old "private" _PyGen_Send C API. This translates to 1.6x increased performance of 'await' calls in micro-benchmarks. Aside from CPython core improvements, this new API will also allow Cython to generate more efficient code, benefiting high-performance IO libraries like uvloop.
* bpo-41780: Fix __dir__ of types.GenericAlias (GH-22262)Batuhan Taskaya2020-09-151-0/+39
| | | Automerge-Triggered-By: @gvanrossum
* bpo-41428: Implementation for PEP 604 (GH-21515)Maggie Moss2020-09-093-8/+490
| | | | | See https://www.python.org/dev/peps/pep-0604/ for more information. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-1635741: Port _string module to multi-phase init (GH-22148)Victor Stinner2020-09-081-9/+5
| | | | Port the _string extension module to the multi-phase initialization API (PEP 489).
* bpo-41732: add iterator to memoryview (GH-22119)dxflores2020-09-081-1/+107
|
* closes bpo-41689: Preserve text signature from tp_doc in C heap type ↵Benjamin Peterson2020-09-021-3/+12
| | | | creation. (GH-22058)
* bpo-41654: Fix deallocator of MemoryError to account for subclasses (GH-22020)Pablo Galindo2020-09-011-2/+12
| | | | | | | When allocating MemoryError classes, there is some logic to use pre-allocated instances in a freelist only if the type that is being allocated is not a subclass of MemoryError. Unfortunately in the destructor this logic is not present so the freelist is altered even with subclasses of MemoryError.
* bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21822)Victor Stinner2020-08-111-2/+2
| | | Automerge-Triggered-By: @tiran
* bpo-41493: Refactoring dictresize (GH-21751)Inada Naoki2020-08-071-26/+41
| | | Split newsize calculation into new function. dictresize() now accepts exact newsize.
* bpo-41431: Optimize dict_merge for copy (GH-21674)Inada Naoki2020-08-041-29/+67
|
* A (very) slight speed improvement for iterating over bytes (#21705)Guido van Rossum2020-08-031-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | My mentee @xvxvxvxvxv noticed that iterating over array.array is slightly faster than iterating over bytes. Looking at the source I observed that arrayiter_next() calls `getitem(ao, it->index++)` wheras striter_next() uses the idiom (paraphrased) item = PyLong_FromLong(seq->ob_sval[it->it_index]); if (item != NULL) ++it->it_next; return item; I'm not 100% sure but I think that the second version has fewer opportunity for the CPU to overlap the `index++` operation with the rest of the code (which in both cases involves a call). So here I am optimistically incrementing the index -- if the PyLong_FromLong() call fails, this will leave the iterator pointing at the next byte, but honestly I doubt that anyone would seriously consider resuming use of the iterator after that kind of failure (it would have to be a MemoryError). And the author of arrayiter_next() made the same consideration (or never ever gave it a thought :-). With this, a loop like for _ in b: pass is now slightly *faster* than the same thing over an equivalent array, rather than slightly *slower* (in both cases a few percent).
* bpo-41342: Convert int.__round__ to Argument Clinic (GH-21549)Serhiy Storchaka2020-07-202-8/+50
|
* bpo-41334: Convert constructors of str, bytes and bytearray to Argument ↵Serhiy Storchaka2020-07-206-87/+293
| | | | Clinic (GH-21535)
* bpo-41343: Convert methods of complex to Argument Clinic (GH-21550)Dong-hee Na2020-07-202-26/+99
|
* bpo-41333: Convert OrderedDict.pop() to Argument Clinic (GH-21534)Serhiy Storchaka2020-07-194-25/+67
|
* bpo-41295: Reimplement the Carlo Verre "hackcheck" (GH-21528)scoder2020-07-181-7/+20
| | | | | Walk down the MRO backwards to find the type that originally defined the final `tp_setattro`, then make sure we are not jumping over intermediate C-level bases with the Python-level call. Automerge-Triggered-By: @gvanrossum
* bpo-41262: Convert memoryview to Argument Clinic. (GH-21421)Serhiy Storchaka2020-07-182-74/+267
|
* Fix a small grammatical mistake in a comment (GH-21526)Brett Cannon2020-07-171-1/+1
| | | Automerge-Triggered-By: @brettcannon
* bpo-40941: Unify implicit and explicit state in the frame and generator ↵Mark Shannon2020-07-172-68/+93
| | | | | | | objects into a single value. (GH-20803) * Merge gen and frame state variables into one. * Replace stack pointer with depth in PyFrameObject. Makes code easier to read and saves a word of memory.
* bpo-36346: Make using the legacy Unicode C API optional (GH-21437)Serhiy Storchaka2020-07-101-23/+58
| | | | Add compile time option USE_UNICODE_WCHAR_CACHE. Setting it to 0 makes the interpreter not using the wchar_t cache and the legacy Unicode C API.
* bpo-39573: Use the Py_TYPE() macro (GH-21433)Victor Stinner2020-07-103-5/+5
| | | Replace obj->ob_type with Py_TYPE(obj).
* bpo-41263: Convert code.__new__ to Argument Clinic (GH-21426)Serhiy Storchaka2020-07-102-38/+173
|
* bpo-29590: fix stack trace for gen.throw() with yield from (#19896)Chris Jerdonek2020-07-091-0/+10
| | | | | | | | * Add failing test. * bpo-29590: fix stack trace for gen.throw() with yield from (GH-NNNN) When gen.throw() is called on a generator after a "yield from", the intermediate stack trace entries are lost. This commit fixes that.
* bpo-41175: Guard against a NULL pointer dereference within bytearrayobject ↵stratakis2020-07-081-1/+3
| | | | | | | (GH-21240) The issue is triggered by the bytearray() + bytearray() operation. Detected by GCC 10 static analysis tool.
* bpo-36346: Undeprecate private function _PyUnicode_AsUnicode(). (GH-21336)Serhiy Storchaka2020-07-051-6/+0
|
* bpo-1635741: Fix unicode_dealloc() for mortal interned string (GH-21270)Victor Stinner2020-07-031-4/+14
| | | | When unicode_dealloc() is called on a mortal interned string, the string reference counter is now reset at zero.
* bpo-39960: Allow heap types in the "Carlo Verre" hack check that override ↵scoder2020-07-031-11/+30
| | | | | "tp_setattro()" (GH-21092) Automerge-Triggered-By: @gvanrossum
* bpo-1635741: Release Unicode interned strings at exit (GH-21269)Victor Stinner2020-07-011-32/+28
| | | | | | | * PyUnicode_InternInPlace() now ensures that interned strings are ready. * Add _PyUnicode_ClearInterned(). * Py_Finalize() now releases Unicode interned strings: call _PyUnicode_ClearInterned().
* bpo-36346: Raise DeprecationWarning when creating legacy Unicode (GH-20933)Inada Naoki2020-06-301-3/+20
|
* bpo-36346: Prepare for removing the legacy Unicode C API (AC only). (GH-21223)Serhiy Storchaka2020-06-301-0/+74
|
* bpo-41123: Remove PyUnicode_AsUnicodeCopy (GH-21209)Inada Naoki2020-06-301-33/+0
|
* bpo-37999: Simplify the conversion code for %c, %d, %x, etc. (GH-20437)Serhiy Storchaka2020-06-293-58/+26
| | | | Since PyLong_AsLong() no longer use __int__, explicit call of PyNumber_Index() before it is no longer needed.