summaryrefslogtreecommitdiffstats
path: root/Objects/rangeobject.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-101291: Rearrange the size bits in PyLongObject (GH-102464)Mark Shannon2023-03-221-1/+1
| | | | | | | | | | * Eliminate all remaining uses of Py_SIZE and Py_SET_SIZE on PyLongObject, adding asserts. * Change layout of size/sign bits in longobject to support future addition of immortal ints and tagged medium ints. * Add functions to hide some internals of long object, and for setting sign and digit count. * Replace uses of IS_MEDIUM_VALUE macro with _PyLong_IsCompact().
* 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-89189: More compact range iterator (GH-27986)Serhiy Storchaka2022-11-301-37/+42
|
* gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)Victor Stinner2022-11-161-3/+1
| | | | Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
* gh-99300: Use Py_NewRef() in Objects/ directory (#99351)Victor Stinner2022-11-101-34/+17
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
* GH-91432: Specialize FOR_ITER (GH-91713)Dennis Sweeney2022-06-211-15/+8
| | | | | * Adds FOR_ITER_LIST and FOR_ITER_RANGE specializations. * Adds _PyLong_AssignValue() internal function to avoid temporary boxing of ints.
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-45030: Fix integer overflow in __reduce__ of the range iterator (GH-28000)Serhiy Storchaka2021-09-041-16/+18
| | | | It happened with fast range iterator when the calculated stop = start + step * len was out of the C long range.
* bpo-45018: Fix rangeiter_reduce in rangeobject.c (GH-27938)chilaxan2021-08-271-1/+1
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-43977: Use tp_flags for collection matching (GH-25723)Mark Shannon2021-04-301-1/+1
| | | | | | | | | | | | | * Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes. * Set relevant flags on collections.abc.Sequence and Mapping. * Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes. * Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING. * Add NEWS * Remove interpreter-state map_abc and seq_abc fields.
* bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)Victor Stinner2020-12-011-2/+2
| | | | | | | | | No longer use deprecated aliases to functions: * Replace PyObject_MALLOC() with PyObject_Malloc() * Replace PyObject_REALLOC() with PyObject_Realloc() * Replace PyObject_FREE() with PyObject_Free() * Replace PyObject_Del() with PyObject_Free() * Replace PyObject_DEL() with PyObject_Free()
* bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)Victor Stinner2020-10-271-22/+31
| | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Objects/ and Python/ directories.
* bpo-41902: Micro optimization for range.index if step is 1 (GH-22479)Dong-hee Na2020-10-211-5/+11
|
* bpo-41902: Micro optimization for compute_item of range (GH-22492)Dong-hee Na2020-10-211-5/+11
|
* bpo-41078: Rename pycore_tupleobject.h to pycore_tuple.h (GH-21056)Victor Stinner2020-06-221-2/+2
|
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+1
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-40170: Add _PyIndex_Check() internal function (GH-19426)Victor Stinner2020-04-081-2/+3
| | | | | | | | | Add _PyIndex_Check() function to the internal C API: fast inlined verson of PyIndex_Check(). Add Include/internal/pycore_abstract.h header file. Replace PyIndex_Check() with _PyIndex_Check() in C files of Objects and Python subdirectories.
* bpo-37207: Add _PyArg_NoKwnames() helper function (GH-18980)Dong-hee Na2020-03-161-2/+1
|
* bpo-37207: Use vectorcall for range() (GH-18464)Petr Viktorin2020-02-181-17/+33
| | | | | | | This continues the `range()` part of #13930. The complete pull request is stalled on discussions around dicts, but `range()` should not be controversial. (And I plan to open PRs for other parts if this is merged.) On top of Mark's change, I unified `range_new` and `range_vectorcall`, which had a lot of duplicate code. https://bugs.python.org/issue37207
* bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)Victor Stinner2020-02-071-2/+2
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)Hai Shi2020-01-301-2/+2
| | | Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
* bpo-39200: Correct the error message for range() empty constructor (GH-17813)Pablo Galindo2020-01-051-29/+44
| | | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-6/+6
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo:34848 : Correct an incorrect docstring for range().index method (GH-9877)Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి)2019-05-031-1/+1
|
* bpo-35444: Unify and optimize the helper for getting a builtin object. ↵Serhiy Storchaka2018-12-111-2/+6
| | | | | | | | (GH-11047) This speeds up pickling of some iterators. This fixes also error handling in pickling methods when fail to look up builtin "getattr".
* Fix a possible crash in range.__reversed__(). (GH-10252)Zackery Spytz2018-10-311-0/+1
|
* closes bpo-34468: Objects/rangeobject.c: Fix an always-false condition in ↵Alexey Izbyshev2018-08-241-4/+4
| | | | | | | | range_repr() (GH-8880) Also, propagate the error from PyNumber_AsSsize_t() because we don't care only about OverflowError which is not reported if the second argument is NULL. Reported by Svace static analyzer.
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-6/+6
| | | | | | | | | (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-30592: Fixed error messages for some builtins. (#1996)Serhiy Storchaka2017-06-081-1/+1
| | | | | Error messages when pass keyword arguments to some builtins that don't support keyword arguments contained double parenthesis: "()()". The regression was introduced by bpo-30534.
* bpo-29878: Add global instances of int for 0 and 1. (#852)Serhiy Storchaka2017-03-301-106/+38
|
* bpo-28876: bool of large range raises OverflowError (#699)4kir42017-03-201-1/+11
|
* Issue #28376: Creating instances of range_iterator by calling range_iteratorSerhiy Storchaka2016-10-081-41/+0
| | | | | type now is disallowed. Calling iter() on range instance is the only way. Patch by Oren Milman.
* Issue #28376: Creating instances of range_iterator by calling range_iteratorSerhiy Storchaka2016-10-081-0/+7
| | | | type now is deprecated. Patch by Oren Milman.
* Merge from 3.5.Serhiy Storchaka2016-10-081-3/+11
|\
| * Issue #28376: The constructor of range_iterator now checks that step is not 0.Serhiy Storchaka2016-10-081-3/+11
| | | | | | | | Patch by Oren Milman.
* | Issue #28045: Merge from 3.5Berker Peksag2016-09-121-1/+1
|\ \ | |/
| * Issue #28045: Fix comment in range_contains_long()Berker Peksag2016-09-121-1/+1
| | | | | | | | Patch by wim glenn.
* | replace PY_LONG_LONG with long longBenjamin Peterson2016-09-061-1/+1
| |
* | Issue #27333: Simplified testing step on 0.Serhiy Storchaka2016-06-181-11/+4
| |
* | Issue #27342: Replaced some Py_XDECREFs with Py_DECREFs.Serhiy Storchaka2016-06-181-5/+5
|/ | | | Patch by Xiang Zhang.
* Issue #26778: Fixed "a/an/and" typos in code comment and documentation.Serhiy Storchaka2016-04-171-1/+1
|
* Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREFSerhiy Storchaka2016-04-101-1/+1
| | | | in places where Py_DECREF was used.
* Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-3/+3
|
* Issue #20440: Applied yet one patch for using Py_SETREF.Serhiy Storchaka2015-12-271-5/+3
| | | | The patch is automatically generated, it replaces the code that uses Py_CLEAR.
* Issue #20440: Massive replacing unsafe attribute setting code with specialSerhiy Storchaka2015-12-241-2/+1
| | | | macro Py_SETREF.
* Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),Serhiy Storchaka2015-05-301-1/+4
|\ | | | | | | | | PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly.
| * Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),Serhiy Storchaka2015-05-301-1/+4
| | | | | | | | | | PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains() to check for and handle errors correctly.
* | merge 3.4 (#22785)Benjamin Peterson2015-04-221-1/+5
|\ \ | |/
| * improved range docstring (closes #22785)Benjamin Peterson2015-04-221-1/+5
| | | | | | | | Patch by Ned Batchelder.
* | Removed unintentional trailing spaces in non-external and non-generated C files.Serhiy Storchaka2015-03-181-2/+2
|/