summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* gh-101409: Improve generated clinic code for self type checks (#101411)Erlend E. Aasland2023-01-316-20/+21
|
* GH-101291: Refactor the `PyLongObject` struct into object header and ↵Mark Shannon2023-01-303-184/+184
| | | | PyLongValue struct. (GH-101292)
* GH-100762: Don't call `gen.throw()` in `gen.close()`, unless necessary. ↵Mark Shannon2023-01-241-1/+23
| | | | | | (GH-101013) * Store exception stack depth in YIELD_VALUE's oparg and use it avoid expensive gen.throw() in gen.close() where possible.
* gh-59956: Allow the "Trashcan" Mechanism to Work Without a Thread State ↵Eric Snow2023-01-231-21/+66
| | | | | | | | | | | | (gh-101209) We've factored out a struct from the two PyThreadState fields. This accomplishes two things: * make it clear that the trashcan-related code doesn't need any other parts of PyThreadState * allows us to use the trashcan mechanism even when there isn't a "current" thread state We still expect the caller to hold the GIL. https://github.com/python/cpython/issues/59956
* gh-100726: Optimize construction of range object for medium sized integers ↵Pieter Eendebak2023-01-211-0/+58
| | | | | | | | (#100810) Use C long arithmetic instead of PyLong arithmetic to compute the range length, where possible. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-101037: Fix potential memory underallocation for zeros of int subtypes ↵Mark Dickinson2023-01-211-0/+5
| | | | | | | | | (#101038) This PR fixes object allocation in long_subtype_new to ensure that there's at least one digit in all cases, and makes sure that the value of that digit is copied over from the source long. Needs backport to 3.11, but not any further: the change to require at least one digit was only introduced for Python 3.11. Fixes #101037.
* GH-100982: Add `COMPARE_AND_BRANCH` instruction (GH-100983)Mark Shannon2023-01-161-0/+8
|
* gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (#101057)Nikita Sobolev2023-01-161-1/+3
|
* gh-86682: Adds sys._getframemodulename as an alternative to using _getframe ↵Steve Dower2023-01-131-1/+4
| | | | | (GH-99520) Also updates calls in collections, doctest, enum, and typing modules to use _getframemodulename first when available.
* GH-100942: Fix incorrect cast in property_copy(). (#100965)Raymond Hettinger2023-01-121-1/+3
|
* GH-81381: Add longer comment _PyType_AllocNoTrack() (GH-100954)Neil Schemenauer2023-01-121-1/+6
| | | | The details on the "nitems+1" expression is a bit subtle so add a longer comment about it.
* GH-100117: Make `co_lines` more efficient (GH-100447)Brandt Bucher2023-01-101-32/+18
|
* GH-100126: Skip incomplete frames in more places (GH-100613)Brandt Bucher2023-01-093-10/+11
|
* gh-100758: Refactor initialisation of frame headers into a single function ↵Irit Katriel2023-01-061-5/+2
| | | | (_PyFrame_Initialize) (GH-100759)
* GH-99005: More intrinsics (GH-100774)Mark Shannon2023-01-061-2/+2
| | | * Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
* GH-100719: Remove the `co_nplaincellvars` field from code objects. (GH-100721)Mark Shannon2023-01-043-12/+6
|
* gh-100720: refactor calculation of number of frame slots for a code object ↵Irit Katriel2023-01-042-3/+3
| | | | into the new function _PyFrame_NumSlotsForCodeObject (#100722)
* gh-100146: Steal references from stack when building a list (#100147)L. A. F. Pereira2023-01-031-0/+21
| | | | | | | | | | When executing the BUILD_LIST opcode, steal the references from the stack, in a manner similar to the BUILD_TUPLE opcode. Implement this by offloading the logic to a new private API, _PyList_FromArraySteal(), that works similarly to _PyTuple_FromArraySteal(). This way, instead of performing multiple stack pointer adjustments while the list is being initialized, the stack is adjusted only once and a fast memory copy operation is performed in one fell swoop.
* gh-100637: Fix int and bool __sizeof__ calculation to include the 1 element ↵Ionite2023-01-021-1/+4
| | | | | | | | ob_digit array for 0 and False (#100663) Fixes behaviour where int (and subtypes like bool) __sizeof__ under-reports true size as it did not take into account the size 1 `ob_digit` array for the zero int. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-87980: Fix the error message for disallowed __weakref__ slots (#25362)Géry Ogam2023-01-011-2/+1
| | | Fix the error message for disallowed `__weakref__` slots.
* gh-94603: micro optimize list.pop (gh-94604)Pieter Eendebak2022-12-271-12/+20
|
* gh-100268: Add is_integer method to int (#100439)Shantanu2022-12-242-1/+33
| | | This improves the lives of type annotation users of `float` - which type checkers implicitly treat as `int|float` because that is what most code actually wants. Before this change a `.is_integer()` method could not be assumed to exist on things annotated as `: float` due to the method not existing on both types.
* gh-99947: Ensure unreported errors are chained for SystemError during import ↵Sebastian Berg2022-12-231-4/+5
| | | | (GH-99946)
* gh-94155: Reduce hash collisions for code objects (#100183)Dennis Sweeney2022-12-231-20/+33
| | | | | | | * Uses a better hashing algorithm to get better dispersion and remove commutativity. * Incorporates `co_firstlineno`, `Py_SIZE(co)`, and bytecode instructions. * This is now the entire set of criteria used in `code_richcompare`, except for `_PyCode_ConstantKey` (which would incorporate the types of `co_consts` rather than just their values).
* gh-92216: improve performance of `hasattr` for type objects (GH-99979)Pieter Eendebak2022-12-232-8/+39
|
* gh-99110: Initialize `frame->previous` in init_frame to fix segmentation ↵Bill Fisher2022-12-231-0/+1
| | | | fault when accessing `frame.f_back` (#100182)
* gh-99540: Constant hash for _PyNone_Type to aid reproducibility (GH-99541)yonillasky2022-12-161-1/+6
| | | Needed for ASLR builds of Python.
* Move stats for the method cache into the `Py_STAT` machinery (GH-100255)Mark Shannon2022-12-151-41/+23
|
* GH-100000: Cleanup and polish various watchers code (GH-99998)Itamar Ostricher2022-12-143-11/+29
| | | | | | * Initialize `type_watchers` array to `NULL`s * Optimize code watchers notification * Optimize func watchers notification
* gh-90111: Minor Cleanup for Runtime-Global Objects (gh-100254)Eric Snow2022-12-141-2/+2
| | | | | | | | * move _PyRuntime.global_objects.interned to _PyRuntime.cached_objects.interned_strings (and use _Py_CACHED_OBJECT()) * rename _PyRuntime.global_objects to _PyRuntime.static_objects (This also relates to gh-96075.) https://github.com/python/cpython/issues/90111
* GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code ↵Mark Shannon2022-12-141-5/+6
| | | | unit. (GH-100223)
* clarify the 4300-digit limit on int-str conversion (#100175)Ned Batchelder2022-12-121-2/+2
|
* GH-98522: Add version number to code objects. (GH-98525)Mark Shannon2022-12-092-4/+5
| | | | | | * Add version number to code object for better versioning of functions. * Improves specialization for closures and list comprehensions.
* GH-100110: Specialize FOR_ITER for tuples (GH-100109)Ken Jin2022-12-091-14/+9
| | | * Specialize FOR_ITER for tuples
* gh-81057: Move More Globals to _PyRuntimeState (gh-100092)Eric Snow2022-12-072-4/+7
| | | https://github.com/python/cpython/issues/81057
* bpo-15999: Accept arbitrary values for boolean parameters. (#15609)Serhiy Storchaka2022-12-038-20/+20
| | | builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
* GH-91054: Add code object watchers API (GH-99859)Itamar Ostricher2022-12-021-0/+63
| | | | | | * Add API to allow extensions to set callback function on creation and destruction of PyCodeObject Co-authored-by: Ye11ow-Flash <janshah@cs.stonybrook.edu>
* gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613)Serhiy Storchaka2022-12-011-0/+3
| | | | Previously *consumed was not set in this case.
* gh-89189: More compact range iterator (GH-27986)Serhiy Storchaka2022-11-301-37/+42
|
* gh-99845: Use size_t type in __sizeof__() methods (#99846)Victor Stinner2022-11-303-14/+11
| | | | | | | | The implementation of __sizeof__() methods using _PyObject_SIZE() now use an unsigned type (size_t) to compute the size, rather than a signed type (Py_ssize_t). Cast explicitly signed (Py_ssize_t) values to unsigned type (Py_ssize_t).
* gh-99845: Clean up _PyObject_VAR_SIZE() usage (#99847)Victor Stinner2022-11-292-11/+12
| | | | | | * code_sizeof() now uses an unsigned type (size_t) to compute the result. * Fix _PyObject_ComputedDictPointer(): cast _PyObject_VAR_SIZE() to Py_ssize_t, rather than long: it's a different type on 64-bit Windows. * Clarify that _PyObject_VAR_SIZE() uses an unsigned type (size_t).
* gh-99845: Change _PyDict_KeysSize() return type to size_t (#99848)Victor Stinner2022-11-292-34/+30
| | | | | | | | * Change _PyDict_KeysSize() and shared_keys_usable_size() return type from signed (Py_ssize_t) to unsigned (size_t) type. * new_values() argument type is now unsigned (size_t). * init_inline_values() now uses size_t rather than int for the 'i' iterator variable. * type.__sizeof__() implementation now uses unsigned (size_t) type.
* gh-89682: [doc] reword docstring of __contains__ to clarify that it returns ↵Ivan Savov2022-11-261-1/+1
| | | | a bool (GH-29043)
* gh-98724: Fix warnings on Py_SETREF() usage (#99781)Victor Stinner2022-11-252-2/+2
| | | Cast argument to the expected type.
* gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)Victor Stinner2022-11-235-26/+13
| | | Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
* gh-99537: Use Py_SETREF() function in C code (#99657)Victor Stinner2022-11-2211-51/+23
| | | | | | | | | | | | | | | Fix potential race condition in code patterns: * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);" * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);" Other changes: * Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);" * Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);" * And remove the "old" variable.
* gh-91053: Add an optional callback that is invoked whenever a function is ↵mpage2022-11-221-0/+68
| | | | modified (#98175)
* gh-99537: Use Py_SETREF() function in longobject C code (#99655)Victor Stinner2022-11-221-49/+24
| | | | Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" in longobject.c and _testcapi/long.c.
* gh-99553: fix bug where an ExceptionGroup subclass can wrap a BaseException ↵Irit Katriel2022-11-181-1/+13
| | | | (GH-99572)
* gh-99443: `descr_set_trampoline_call` return type should be `int` not ↵Hood Chatham2022-11-161-1/+1
| | | | `PyObject*` (#99444)