summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40943: Replace PY_FORMAT_SIZE_T with "z" (GH-20781)Victor Stinner2020-06-104-65/+62
| | | | | | | The PEP 353, written in 2005, introduced PY_FORMAT_SIZE_T. Python no longer supports macOS 10.4 and Visual Studio 2010, but requires more recent macOS and Visual Studio versions. In 2020 with Python 3.10, it is now safe to use directly "%zu" to format size_t and "%zi" to format Py_ssize_t.
* bpo-40703: Let PyType_FromSpec() set "type.__module__" only if it is not set ↵scoder2020-06-101-15/+20
| | | | yet. (GH-20273)
* bpo-40889: Optimize dict.items() ^ dict.items() (GH-20718)Dennis Sweeney2020-06-101-0/+90
|
* bpo-29882: Add _Py_popcount32() function (GH-20518)Victor Stinner2020-06-082-9/+8
| | | | | | * Rename pycore_byteswap.h to pycore_bitutils.h. * Move popcount_digit() to pycore_bitutils.h as _Py_popcount32(). * _Py_popcount32() uses GCC and clang builtin function if available. * Add unit tests to _Py_popcount32().
* bpo-40887: Don't use finalized free lists (GH-20700)Victor Stinner2020-06-085-3/+76
| | | | | | In debug mode, ensure that free lists are no longer used after being finalized. Set numfree to -1 in finalization functions (eg. _PyList_Fini()), and then check that numfree is not equal to -1 before using a free list (e.g list_dealloc()).
* bpo-40881: Fix unicode_release_interned() (GH-20699)Victor Stinner2020-06-071-2/+2
| | | Use Py_SET_REFCNT() in unicode_release_interned().
* bpo-40724: Support setting buffer slots from type specs (GH-20648)scoder2020-06-061-2/+2
| | | This is not part of the limited API but makes the buffer slots available for type specs.
* bpo-40521: Make async gen free lists per-interpreter (GH-20643)Victor Stinner2020-06-051-40/+38
| | | | | | | | | Each interpreter now has its own asynchronous generator free lists: * Move async gen free lists into PyInterpreterState. * Move _PyAsyncGen_MAXFREELIST define to pycore_interp.h * Add _Py_async_gen_state structure. * Add tstate parameter to _PyAsyncGen_ClearFreeLists and _PyAsyncGen_Fini().
* bpo-40521: Make list free list per-interpreter (GH-20642)Victor Stinner2020-06-051-31/+29
| | | | | | | | | | | | Each interpreter now has its own list free list: * Move list numfree and free_list into PyInterpreterState. * Add _Py_list_state structure. * Add tstate parameter to _PyList_ClearFreeList() and _PyList_Fini(). * Remove "#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS". * _PyGC_Fini() clears gcstate->garbage list which can be stored in the list free list. Call _PyGC_Fini() before _PyList_Fini() to prevent leaking this list.
* bpo-40521: Make frame free list per-interpreter (GH-20638)Victor Stinner2020-06-041-49/+37
| | | | | | | | | | Each interpreter now has its own frame free list: * Move frame free list into PyInterpreterState. * Add _Py_frame_state structure. * Add tstate parameter to _PyFrame_ClearFreeList() and _PyFrame_Fini(). * Remove "#if PyFrame_MAXFREELIST > 0". * Remove "#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS".
* bpo-40521: Make slice cache per-interpreter (GH-20637)Victor Stinner2020-06-041-14/+15
| | | | | | Each interpreter now has its own slice cache: * Move slice cache into PyInterpreterState. * Add tstate parameter to _PySlice_Fini().
* bpo-40521: Make float free list per-interpreter (GH-20636)Victor Stinner2020-06-041-26/+29
| | | | | | | | Each interpreter now has its own float free list: * Move tuple numfree and free_list into PyInterpreterState. * Add _Py_float_state structure. * Add tstate parameter to _PyFloat_ClearFreeList() and _PyFloat_Fini().
* bpo-40521: Make tuple free list per-interpreter (GH-20247)Victor Stinner2020-06-041-58/+53
| | | | | | | | | | Each interpreter now has its own tuple free lists: * Move tuple numfree and free_list arrays into PyInterpreterState. * Define PyTuple_MAXSAVESIZE and PyTuple_MAXFREELIST macros in pycore_interp.h. * Add _Py_tuple_state structure. Pass it explicitly to tuple_alloc(). * Add tstate parameter to _PyTuple_ClearFreeList() * Each interpreter now has its own empty tuple singleton.
* Don't raise an exception on normal return from generator. (GH-19473)Mark Shannon2020-06-041-1/+2
|
* Fix MSVC warning in frameobject.c (GH-20590)Ammar Askar2020-06-041-1/+3
|
* bpo-39465: Cleanup _PyUnicode_FromId() code (GH-20595)Victor Stinner2020-06-021-10/+16
| | | Work on a local variable before filling _Py_Identifier members.
* bpo-40839: PyDict_GetItem() requires the GIL (GH-20580)Victor Stinner2020-06-021-29/+26
| | | | Calling PyDict_GetItem() without GIL held had been allowed for historical reason. It is no longer allowed.
* bpo-29882: Add an efficient popcount method for integers (#771)Niklas Fiekas2020-05-292-1/+96
| | | | | | | | | | | | | | | | | | | | | | | * bpo-29882: Add an efficient popcount method for integers * Update 'sign bit' and versionadded in docs * Add entry to whatsnew document * Doc: use positive example, mention population count * Minor cleanups of the core code * Move popcount_digit closer to where it's used * Use z instead of self after conversion * Add 'absolute value' and 'population count' to docstring * Fix clinic error about missing summary line * Ensure popcount_digit is portable with 64-bit ints Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-2813-56/+64
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-39573: Convert Py_REFCNT and Py_SIZE to functions (GH-20429)Victor Stinner2020-05-271-1/+1
| | | | | | | | | | | Convert Py_REFCNT() and Py_SIZE() macros to static inline functions. They cannot be used as l-value anymore: use Py_SET_REFCNT() and Py_SET_SIZE() to set an object reference count and size. Replace &Py_SIZE(self) with &((PyVarObject*)self)->ob_size in arraymodule.c. This change is backward incompatible on purpose, to prepare the C API for an opaque PyObject structure.
* bpo-37999: Fix outdated __int__ and nb_int references in comments (GH-20449)Mark Dickinson2020-05-271-8/+8
| | | | | | | | | * Fix outdated __int__ and nb_int references in comments * Also update C-API documentation * Add back missing 'method' word * Remove .. deprecated notices
* bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for ↵Pablo Galindo2020-05-272-93/+11
| | | | | | | | | PyType_FromSpec types (reverts GH-19414) (GH-20264) Heap types now always visit the type in tp_traverse. See added docs for details. This reverts commit 0169d3003be3d072751dd14a5c84748ab63a249f. Automerge-Triggered-By: @encukou
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-2611-338/+38
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-39573: Fix buildbot failure for tupleobject.c (GH-20391)Dong-hee Na2020-05-251-1/+1
|
* bpo-34397: Remove redundant overflow checks in list and tuple ↵Sergey Fedoseev2020-05-252-15/+4
| | | | implementation. (GH-8757)
* bpo-37973: Improve the docstrings of sys.float_info (GH-19218)Zackery Spytz2020-05-241-2/+4
| | | Taken from https://docs.python.org/3/library/sys.html#sys.float_info
* Remove spurious NULL in descrobject.c (GH-20344)Hai Shi2020-05-241-1/+0
| | | Co-authored-by: hai shi <shihai1991@126.com>
* bpo-40696: Fix a hang that can arise after gen.throw() (GH-20287)Chris Jerdonek2020-05-221-4/+6
| | | | | | | | This updates _PyErr_ChainStackItem() to use _PyErr_SetObject() instead of _PyErr_ChainExceptions(). This prevents a hang in certain circumstances because _PyErr_SetObject() performs checks to prevent cycles in the exception context chain while _PyErr_ChainExceptions() doesn't.
* bpo-40521: Fix update_slot() when INTERN_NAME_STRINGS is not defined (#20246)Victor Stinner2020-05-191-1/+10
| | | | Fix type update_slot() function when the macro INTERN_NAME_STRINGS is not defined: use _PyUnicode_EQ() in this case.
* Use _PyErr_ChainStackItem() inside gen_send_ex(). (GH-20173)Chris Jerdonek2020-05-181-10/+2
| | | _PyErr_ChainStackItem was just added in GH-19951 (for bpo-31033).
* bpo-31033: Improve the traceback for cancelled asyncio tasks (GH-19951)Chris Jerdonek2020-05-181-17/+3
| | | | | When an asyncio.Task is cancelled, the exception traceback now starts with where the task was first interrupted. Previously, the traceback only had "depth one."
* bpo-39075: types.SimpleNamespace no longer sorts attributes in its repr ↵Zackery Spytz2020-05-161-2/+0
| | | | (GH-19430)
* bpo-40521: Add PyInterpreterState.unicode (GH-20081)Victor Stinner2020-05-131-31/+33
| | | | | | | Move PyInterpreterState.fs_codec into a new PyInterpreterState.unicode structure. Give a name to the fs_codec structure and use this structure in unicodeobject.c.
* bpo-29587: Make gen.throw() chain exceptions with yield from (GH-19858)Chris Jerdonek2020-05-131-10/+12
| | | | | | | | | | | | The previous commits on bpo-29587 got exception chaining working with gen.throw() in the `yield` case. This patch also gets the `yield from` case working. As a consequence, implicit exception chaining now also works in the asyncio scenario of awaiting on a task when an exception is already active. Tests are included for both the asyncio case and the pure generator-only case.
* bpo-39465: Remove _PyUnicode_ClearStaticStrings() from C API (GH-20078)Victor Stinner2020-05-131-3/+3
| | | | Remove the _PyUnicode_ClearStaticStrings() function from the C API. Make the function fully private (declare it with "static").
* bpo-38787: Add PyCFunction_CheckExact() macro for exact type checks (GH-20024)scoder2020-05-121-1/+1
| | | | | … now that we allow subtypes of PyCFunction. Also add PyCMethod_CheckExact() and PyCMethod_Check() for checks against the PyCMethod subtype.
* bpo-40596: Fix str.isidentifier() for non-canonicalized strings containing ↵Serhiy Storchaka2020-05-121-4/+22
| | | | non-BMP characters on Windows. (GH-20053)
* bpo-40593: Improve syntax errors for invalid characters in source code. ↵Serhiy Storchaka2020-05-121-23/+41
| | | | (GH-20033)
* bpo-39465: Don't access directly _Py_Identifier members (GH-20043)Victor Stinner2020-05-112-8/+8
| | | | | * Replace id->object with _PyUnicode_FromId(&id) * Use _Py_static_string_init(str) macro to initialize statically name_op in typeobject.c.
* bpo-40584: Update PyType_FromModuleAndSpec() to process tp_vectorcall_offset ↵Hai Shi2020-05-111-2/+12
| | | | (GH-20026)
* bpo-40575: Avoid unnecessary overhead in _PyDict_GetItemIdWithError() (GH-20018)scoder2020-05-111-1/+3
| | | | | Avoid unnecessary overhead in _PyDict_GetItemIdWithError() by calling _PyDict_GetItem_KnownHash() instead of the more generic PyDict_GetItemWithError(), since we already know the hash of interned strings.
* Improve code clarity for the set lookup logic (GH-20028)Raymond Hettinger2020-05-101-125/+55
|
* bpo-37986: Improve perfomance of PyLong_FromDouble() (GH-15611)Sergey Fedoseev2020-05-102-23/+17
| | | | | | | | | * bpo-37986: Improve perfomance of PyLong_FromDouble() * Use strict bound check for safety and symmetry * Remove possibly outdated performance claims Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-40273: Reversible mappingproxy (FH-19513)Zackery Spytz2020-05-081-0/+9
|
* bpo-38787: C API for module state access from extension methods (PEP 573) ↵Petr Viktorin2020-05-074-12/+182
| | | | | | | | | (GH-19936) Module C state is now accessible from C-defined heap type methods (PEP 573). Patch by Marcel Plch and Petr Viktorin. Co-authored-by: Marcel Plch <mplch@redhat.com> Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-40521: Disable list free list in subinterpreters (GH-19959)Victor Stinner2020-05-061-1/+8
| | | | | | When Python is built with experimental isolated interpreters, disable the list free list. Temporary workaround until this cache is made per-interpreter.
* bpo-40521: Disable method cache in subinterpreters (GH-19960)Victor Stinner2020-05-061-3/+19
| | | | | | When Python is built with experimental isolated interpreters, disable the type method cache. Temporary workaround until the cache is made per-interpreter.
* bpo-40523: Add pass-throughs for hash() and reversed() to weakref.proxy ↵Pablo Galindo2020-05-051-1/+18
| | | | objects (GH-19946)
* bpo-40521: Disable free lists in subinterpreters (GH-19937)Victor Stinner2020-05-053-80/+162
| | | | | | | | | When Python is built with experimental isolated interpreters, disable tuple, dict and free free lists. Temporary workaround until these caches are made per-interpreter. Add frame_alloc() and frame_get_builtins() subfunctions to simplify _PyFrame_New_NoTrack().
* bpo-40521: Disable Unicode caches in isolated subinterpreters (GH-19933)Victor Stinner2020-05-052-15/+79
| | | | | | | When Python is built in the experimental isolated subinterpreters mode, disable Unicode singletons and Unicode interned strings since they are shared by all interpreters. Temporary workaround until these caches are made per-interpreter.