Christian Heimes
cbab997efb
bpo-45723: Prepare support for autoconf 2.71 (GH-29441)
2021-11-08 19:31:14 +01:00
Tim Peters
51ed2c56a1
bpo-45530: speed listobject.c's unsafe_tuple_compare() (GH-29076)
...
Keep track of whether unsafe_tuple_compare() calls are resolved by the very
first tuple elements, and adjust strategy accordingly. This can significantly
cut the number of calls made to the full-blown PyObject_RichCompareBool(),
and especially when duplicates are rare.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-10-24 22:27:24 -05:00
Christian Heimes
9942f42a93
bpo-45522: Allow to disable freelists on build time (GH-29056)
...
Freelists for object structs can now be disabled. A new ``configure``
option ``--without-freelists`` can be used to disable all freelists
except empty tuple singleton. Internal Py*_MAXFREELIST macros can now
be defined as 0 without causing compiler warnings and segfaults.
Signed-off-by: Christian Heimes <christian@python.org>
2021-10-21 06:12:20 -07:00
Christian Clauss
5f401f1040
Fix typos in the Objects directory (GH-28766)
2021-10-06 16:57:10 -07:00
Serhiy Storchaka
f25f2e2e8c
Clean up initialization __class_getitem__ with Py_GenericAlias. (GH-28450)
...
The cast to PyCFunction is redundant. Overuse of redundant casts
can hide actual bugs.
2021-09-19 18:05:30 +03:00
Tim Peters
5cb4c672d8
bpo-34561: Switch to Munro & Wild "powersort" merge strategy. ( #28108 )
...
For list.sort(), replace our ad hoc merge ordering strategy with the principled, elegant,
and provably near-optimal one from Munro and Wild's "powersort".
2021-09-06 12:54:41 -05:00
Serhiy Storchaka
e5c8ddb171
bpo-44707: Fix an undefined behavior of the null pointer arithmetic (GH-27292)
2021-07-29 12:36:24 +01:00
Mark Shannon
069e81ab3d
bpo-43977: Use tp_flags for collection matching (GH-25723)
...
* 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.
2021-04-30 09:50:28 +01:00
Brandt Bucher
145bf269df
bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)
...
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2021-02-26 14:51:55 -08:00
Victor Stinner
bcb094b41f
bpo-43268: Pass interp rather than tstate to internal functions (GH-24580)
...
Pass the current interpreter (interp) rather than the current Python
thread state (tstate) to internal functions which only use the
interpreter.
Modified functions:
* _PyXXX_Fini() and _PyXXX_ClearFreeList() functions
* _PyEval_SignalAsyncExc(), make_pending_calls()
* _PySys_GetObject(), sys_set_object(), sys_set_object_id(), sys_set_object_str()
* should_audit(), set_flags_from_config(), make_flags()
* _PyAtExit_Call()
* init_stdio_encoding()
* etc.
2021-02-19 15:10:45 +01:00
Victor Stinner
00d7abd7ef
bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)
...
No longer use deprecated aliases to functions:
* Replace PyMem_MALLOC() with PyMem_Malloc()
* Replace PyMem_REALLOC() with PyMem_Realloc()
* Replace PyMem_FREE() with PyMem_Free()
* Replace PyMem_Del() with PyMem_Free()
* Replace PyMem_DEL() with PyMem_Free()
Modify also the PyMem_DEL() macro to use directly PyMem_Free().
2020-12-01 09:56:42 +01:00
Jeong Ukjae
5b96370030
Fix typo in Object/listobject.c (GH-21079)
2020-06-29 21:56:56 +03:00
Victor Stinner
522691c46e
bpo-40521: Cleanup code of free lists (GH-21082)
...
Add get_xxx_state() function to factorize duplicated code.
2020-06-23 16:40:40 +02:00
Victor Stinner
384621c42f
bpo-41078: Rename pycore_tupleobject.h to pycore_tuple.h (GH-21056)
2020-06-22 17:27:35 +02:00
Victor Stinner
bcb198385d
bpo-40887: Don't use finalized free lists (GH-20700)
...
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()).
2020-06-08 02:14:47 +02:00
Victor Stinner
88ec919010
bpo-40521: Make list free list per-interpreter (GH-20642)
...
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.
2020-06-05 02:05:41 +02:00
Sergey Fedoseev
e682b26a6b
bpo-34397: Remove redundant overflow checks in list and tuple implementation. (GH-8757)
2020-05-25 07:54:40 -07:00
Victor Stinner
b7aa23d29f
bpo-40521: Disable list free list in subinterpreters (GH-19959)
...
When Python is built with experimental isolated interpreters, disable
the list free list.
Temporary workaround until this cache is made per-interpreter.
2020-05-06 19:05:27 +02:00
Victor Stinner
ae00a5a885
bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769)
...
Remove the following function from the C API:
* PyAsyncGen_ClearFreeLists()
* PyContext_ClearFreeList()
* PyDict_ClearFreeList()
* PyFloat_ClearFreeList()
* PyFrame_ClearFreeList()
* PyList_ClearFreeList()
* PySet_ClearFreeList()
* PyTuple_ClearFreeList()
Make these functions private, move them to the internal C API and
change their return type to void.
Call explicitly PyGC_Collect() to free all free lists.
Note: PySet_ClearFreeList() did nothing.
2020-04-29 02:29:20 +02:00
Victor Stinner
e5014be049
bpo-40268: Remove a few pycore_pystate.h includes (GH-19510)
2020-04-14 17:52:15 +02:00
Victor Stinner
a15e260b70
bpo-40170: Add _PyIndex_Check() internal function (GH-19426)
...
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.
2020-04-08 02:01:56 +02:00
Guido van Rossum
48b069a003
bpo-39481: Implementation for PEP 585 ( #18239 )
...
This implements things like `list[int]`,
which returns an object of type `types.GenericAlias`.
This object mostly acts as a proxy for `list`,
but has attributes `__origin__` and `__args__`
that allow recovering the parts (with values `list` and `(int,)`.
There is also an approximate notion of type variables;
e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`.
Type variables are objects of type `typing.TypeVar`.
2020-04-07 09:50:06 -07:00
Petr Viktorin
ce105541f8
bpo-37207: Use vectorcall for list() (GH-18928)
...
Speed up calls to list() by using the PEP 590 vectorcall
calling convention. Patch by Mark Shannon.
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2020-03-30 14:16:16 +02:00
Serhiy Storchaka
2fe815edd6
bpo-38373: Change list overallocating strategy. (GH-18952)
...
* Add padding to make the allocated size multiple of 4.
* Do not overallocate if the new size is closer to overalocated size
than to the old size.
2020-03-17 23:46:00 +02:00
Andy Lester
dffe4c0709
bpo-39573: Finish converting to new Py_IS_TYPE() macro (GH-18601)
2020-03-04 14:15:20 +01:00
sweeneyde
be7ead62db
bpo-39737: Remove code repitition in list_richcompare (GH-18638)
...
I may speed up list comparison on some platforms.
2020-02-26 09:00:35 +02:00
Petr Viktorin
ffd9753a94
bpo-39245: Switch to public API for Vectorcall (GH-18460)
...
The bulk of this patch was generated automatically with:
for name in \
PyObject_Vectorcall \
Py_TPFLAGS_HAVE_VECTORCALL \
PyObject_VectorcallMethod \
PyVectorcall_Function \
PyObject_CallOneArg \
PyObject_CallMethodNoArgs \
PyObject_CallMethodOneArg \
;
do
echo $name
git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g"
done
old=_PyObject_FastCallDict
new=PyObject_VectorcallDict
git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g"
and then cleaned up:
- Revert changes to in docs & news
- Revert changes to backcompat defines in headers
- Nudge misaligned comments
2020-02-11 17:46:57 +01:00
Victor Stinner
60ac6ed557
bpo-39573: Use Py_SET_SIZE() function (GH-18402)
...
Replace direct acccess to PyVarObject.ob_size with usage of
the Py_SET_SIZE() function.
2020-02-07 23:18:08 +01:00
Victor Stinner
58ac700fb0
bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)
...
Replace direct access to PyObject.ob_type with Py_TYPE().
2020-02-07 03:04:21 +01:00
Victor Stinner
c6e5c1123b
bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)
...
Remove:
* COUNT_ALLOCS macro
* sys.getcounts() function
* SHOW_ALLOC_COUNT code in listobject.c
* SHOW_TRACK_COUNT code in tupleobject.c
* PyConfig.show_alloc_count field
* -X showalloccount command line option
* @test.support.requires_type_collecting decorator
2020-02-03 15:17:15 +01:00
Dong-hee Na
9e1ed518a5
bpo-39453: Add testcase for bpo-39453 (GH-18202)
...
https://bugs.python.org/issue39453
Automerge-Triggered-By: @pablogsal
Automerge-Triggered-By: @pablogsal
2020-01-27 09:04:25 -08:00
Dong-hee Na
4dbf2d8c67
bpo-39453: Make list.__contains__ hold strong references to avoid crashes (GH-18181)
2020-01-27 15:02:23 +00:00
Dong-hee Na
14d80d0b60
bpo-39425: Fix list.count performance regression (GH-18119)
...
https://bugs.python.org/issue39425
Automerge-Triggered-By: @pablogsal
2020-01-22 09:36:54 -08:00
Inada Naoki
dfef986f12
bpo-38588: Optimize list comparison. (GH-17766)
...
Mitigate performance regression of the list comparison caused by 2d5bf56
.
2019-12-31 10:58:37 +09:00
Dong-hee Na
2d5bf568ea
bpo-38588: Fix possible crashes in dict and list when calling PyObject_RichCompareBool (GH-17734)
...
Take strong references before calling PyObject_RichCompareBool to protect against the case
where the object dies during the call.
2019-12-31 01:04:22 +00:00
Zackery Spytz
d9e561d23d
bpo-38610: Fix possible crashes in several list methods (GH-17022)
...
Hold strong references to list elements while calling PyObject_RichCompareBool().
2019-12-30 19:32:58 +00:00
HongWeipeng
3c87a667bb
bpo-36946:Fix possible signed integer overflow when handling slices. (GH-15639)
...
This is a complement to PR 13375.
2019-09-08 13:15:56 +03:00
Victor Stinner
bed4817d52
Make PyXXX_Fini() functions private (GH-15531)
...
For example, rename PyTuple_Fini() to _PyTuple_Fini().
These functions are only declared in the internal C API.
2019-08-27 00:12:32 +02:00
Serhiy Storchaka
18b711c5a7
bpo-37648: Fixed minor inconsistency in some __contains__. (GH-14904)
...
The collection's item is now always at the left and
the needle is on the right of ==.
2019-08-04 14:12:48 +03:00
Jeroen Demeyer
196a530e00
bpo-37483: add _PyObject_CallOneArg() function ( #14558 )
2019-07-04 19:31:34 +09:00
Tim Hoffmann
5c22476c01
Improve docstring of list.sort (GH-8516)
2019-05-31 21:10:02 -07:00
Jeroen Demeyer
530f506ac9
bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async (GH-13464)
...
Automatically replace
tp_print -> tp_vectorcall_offset
tp_compare -> tp_as_async
tp_reserved -> tp_as_async
2019-05-30 19:13:39 -07:00
Victor Stinner
331a6a56e9
bpo-36763: Implement the PEP 587 (GH-13592)
...
* Add a whole new documentation page:
"Python Initialization Configuration"
* PyWideStringList_Append() return type is now PyStatus,
instead of int
* PyInterpreterState_New() now calls PyConfig_Clear() if
PyConfig_InitPythonConfig() fails.
* Rename files:
* Python/coreconfig.c => Python/initconfig.c
* Include/cpython/coreconfig.h => Include/cpython/initconfig.h
* Include/internal/: pycore_coreconfig.h => pycore_initconfig.h
* Rename structures
* _PyCoreConfig => PyConfig
* _PyPreConfig => PyPreConfig
* _PyInitError => PyStatus
* _PyWstrList => PyWideStringList
* Rename PyConfig fields:
* use_module_search_paths => module_search_paths_set
* module_search_path_env => pythonpath_env
* Rename PyStatus field: _func => func
* PyInterpreterState: rename core_config field to config
* Rename macros and functions:
* _PyCoreConfig_SetArgv() => PyConfig_SetBytesArgv()
* _PyCoreConfig_SetWideArgv() => PyConfig_SetArgv()
* _PyCoreConfig_DecodeLocale() => PyConfig_SetBytesString()
* _PyInitError_Failed() => PyStatus_Exception()
* _Py_INIT_ERROR_TYPE_xxx enums => _PyStatus_TYPE_xxx
* _Py_UnixMain() => Py_BytesMain()
* _Py_ExitInitError() => Py_ExitStatusException()
* _Py_PreInitializeFromArgs() => Py_PreInitializeFromBytesArgs()
* _Py_PreInitializeFromWideArgs() => Py_PreInitializeFromArgs()
* _Py_PreInitialize() => Py_PreInitialize()
* _Py_RunMain() => Py_RunMain()
* _Py_InitializeFromConfig() => Py_InitializeFromConfig()
* _Py_INIT_XXX() => _PyStatus_XXX()
* _Py_INIT_FAILED() => _PyStatus_EXCEPTION()
* Rename 'err' PyStatus variables to 'status'
* Convert RUN_CODE() macro to config_run_code() static inline function
* Remove functions:
* _Py_InitializeFromArgs()
* _Py_InitializeFromWideArgs()
* _PyInterpreterState_GetCoreConfig()
2019-05-27 16:39:22 +02:00
Alexey Izbyshev
6bc5917903
bpo-35091: Objects/listobject.c: Replace overflow checks in gallop fu… (GH-10202)
...
…nctions with asserts
The actual overflow can never happen because of the following:
* The size of a list can't be greater than PY_SSIZE_T_MAX / sizeof(PyObject*).
* The size of a pointer on all supported plaftorms is at least 4 bytes.
* ofs is positive and less than the list size at the beginning of each iteration.
https://bugs.python.org/issue35091
2019-05-22 17:01:08 -07:00
Jeroen Demeyer
351c67416b
bpo-35983: skip trashcan for subclasses (GH-11841)
...
Add new trashcan macros to deal with a double deallocation that could occur when the `tp_dealloc` of a subclass calls the `tp_dealloc` of a base class and that base class uses the trashcan mechanism.
Patch by Jeroen Demeyer.
2019-05-10 19:21:10 +02:00
Rémi Lapeyre
dd5417afcf
bpo-36218: Fix handling of heterogeneous values in list.sort (GH-12209)
2019-03-25 00:25:37 -07:00
Sergey Fedoseev
234531b446
bpo-36030: Add _PyTuple_FromArray() function (GH-11954)
2019-02-25 17:59:12 +01:00
Zackery Spytz
ebc793d6ac
bpo-33989: Ensure that ms.key_compare is always initialized in list_sort_impl(). (GH-8710)
2019-02-21 09:47:14 +02:00
Sergey Fedoseev
ef1b88bf57
bpo-36062: Minor speed-up for list slicing and copying. (GH-11967)
2019-02-21 08:51:52 +02:00
sth
f8b534477a
closes bpo-35623: Fix integer overflow when sorting large lists (GH-11380)
...
There is already a `Py_ssize_t i` defined at function scope that is used
for similar loops. By removing the local `int i` declaration that `i` is
used, which has the appropriate type.
2019-01-01 18:01:54 -08:00
Sergey Fedoseev
0e5f771f38
bpo-33234: Simplify list_preallocate_exact() (GH-11220)
2018-12-29 22:31:36 +00:00
Serhiy Storchaka
bb86bf4c4e
bpo-35444: Unify and optimize the helper for getting a builtin object. (GH-11047)
...
This speeds up pickling of some iterators.
This fixes also error handling in pickling methods when fail to
look up builtin "getattr".
2018-12-11 08:28:18 +02:00
Victor Stinner
bcda8f1d42
bpo-35081: Add Include/internal/pycore_object.h (GH-10640)
...
Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from
Include/objimpl.h to Include/internal/pycore_object.h.
2018-11-21 22:27:47 +01:00
Victor Stinner
621cebe81b
bpo-35081: Rename internal headers (GH-10275)
...
Rename Include/internal/ headers:
* pycore_hash.h -> pycore_pyhash.h
* pycore_lifecycle.h -> pycore_pylifecycle.h
* pycore_mem.h -> pycore_pymem.h
* pycore_state.h -> pycore_pystate.h
Add missing headers to Makefile.pre.in and PCbuild:
* pycore_condvar.h.
* pycore_hamt.h
* pycore_pyhash.h
2018-11-12 16:53:38 +01:00
Victor Stinner
e281f7d80c
bpo-35081: Move accu.h to Include/internal/pycore_accu.h (GH-10271)
...
The accu.h header is no longer part of the Python C API: it has been
moved to the "internal" headers which are restricted to Python
itself.
Replace #include "accu.h" with #include "pycore_accu.h".
2018-11-01 02:30:36 +01:00
Victor Stinner
27e2d1f219
bpo-35081: Add pycore_ prefix to internal header files (GH-10263)
...
* Rename Include/internal/ header files:
* pyatomic.h -> pycore_atomic.h
* ceval.h -> pycore_ceval.h
* condvar.h -> pycore_condvar.h
* context.h -> pycore_context.h
* pygetopt.h -> pycore_getopt.h
* gil.h -> pycore_gil.h
* hamt.h -> pycore_hamt.h
* hash.h -> pycore_hash.h
* mem.h -> pycore_mem.h
* pystate.h -> pycore_state.h
* warnings.h -> pycore_warnings.h
* PCbuild project, Makefile.pre.in, Modules/Setup: add the
Include/internal/ directory to the search paths of header files.
* Update includes. For example, replace #include "internal/mem.h"
with #include "pycore_mem.h".
2018-11-01 00:52:28 +01:00
Pablo Galindo
372d705d95
bpo-33234 Improve list() pre-sizing for inputs with known lengths (GH-9846)
...
The list() constructor isn't taking full advantage of known input
lengths or length hints. This commit makes the constructor
pre-size and not over-allocate when the input size is known (the
input collection implements __len__). One on the main advantages is
that this provides 12% difference in memory savings due to the difference
between overallocating and allocating exactly the input size.
For efficiency purposes and to avoid a performance regression for small
generators and collections, the size of the input object is calculated using
__len__ and not __length_hint__, as the later is considerably slower.
2018-10-28 20:16:26 +00:00
Raymond Hettinger
f1aa8aed4a
Micro-optimize list index range checks (GH-9784)
2018-10-10 20:37:28 -07:00
Sergey Fedoseev
2fc46979b8
bpo-34151: Improve performance of some list operations (GH-8332)
2018-08-11 21:12:07 +08:00
Victor Stinner
caba55b3b7
bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)
...
sys_setcheckinterval() now uses a local variable to parse arguments,
before writing into interp->check_interval.
2018-08-03 15:33:52 +02:00
Siddhesh Poyarekar
55edd0c185
bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. (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.
2018-04-29 21:59:33 +03:00
Eddie Elizondo
745dc65b17
closes bpo-32898: Fix debug build crash with COUNT_ALLOCS (GH-5800)
2018-02-21 20:55:18 -08:00
Victor Stinner
8017b804a0
bpo-28685: Fix compiler warning (GH-5423)
2018-01-29 13:47:06 +01:00
embg
1e34da49ef
bpo-28685: Optimize sorted() list.sort() with type-specialized comparisons ( #582 )
2018-01-28 19:03:23 -08:00
Serhiy Storchaka
1fb72d2ad2
bpo-32137: The repr of deeply nested dict now raises a RecursionError ( #4570 )
...
instead of crashing due to a stack overflow.
This perhaps will fix similar problems in other extension types.
2017-12-03 22:12:11 +02:00
Victor Stinner
25420fe290
bpo-32030: Add more options to _PyCoreConfig ( #4485 )
...
Py_Main() now handles two more -X options:
* -X showrefcount: new _PyCoreConfig.show_ref_count field
* -X showalloccount: new _PyCoreConfig.show_alloc_count field
2017-11-20 18:12:22 -08:00
stratakis
e8b1965639
bpo-23699: Use a macro to reduce boilerplate code in rich comparison functions (GH-793)
2017-11-02 20:32:54 +10:00
Eric Snow
2ebc5ce42a
bpo-30860: Consolidate stateful runtime globals. ( #3397 )
...
* group the (stateful) runtime globals into various topical structs
* consolidate the topical structs under a single top-level _PyRuntimeState struct
* add a check-c-globals.py script that helps identify runtime globals
Other globals are excluded (see globals.txt and check-c-globals.py).
2017-09-07 23:51:28 -06:00
Serhiy Storchaka
b879fe82e7
Expand the PySlice_GetIndicesEx macro. ( #1023 )
2017-04-08 09:53:51 +03:00
Serhiy Storchaka
80ec8364f1
bpo-29748: Added the slice index converter in Argument Clinic. ( #549 )
2017-03-19 19:37:40 +02:00
Serhiy Storchaka
202fda55c2
bpo-24037: Add Argument Clinic converter `bool(accept={int})`. ( #485 )
2017-03-12 10:10:47 +02:00
Serhiy Storchaka
fdd42c481e
bpo-20185: Convert list object implementation to Argument Clinic. ( #542 )
2017-03-11 09:19:20 +02:00
Serhiy Storchaka
2e5642422f
bpo-29695: Remove bad keyword parameters in int(), bool(), float(), list() and tuple(). ( #518 )
2017-03-06 17:01:06 +02:00
Serhiy Storchaka
58d23e6806
bpo-29695: Deprecated using bad named keyword arguments in builtings: ( #486 )
...
int(), bool(), float(), list() and tuple(). Specify the value as a
positional argument instead.
2017-03-06 00:53:39 +02:00
Xiang Zhang
4cee049f5b
bpo-27660: remove unnecessary overflow checks in list_resize (GH-189)
2017-02-22 12:32:30 +08:00
Serhiy Storchaka
228b12edcc
Issue #28999 : Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
...
possible. Patch is writen with Coccinelle.
2017-01-23 09:47:21 +02:00
Serhiy Storchaka
7cf8bebb07
Issue #29331 : Simplified argument parsing in sorted() and list.sort().
2017-01-21 23:05:00 +02:00
Martin Panter
94b39ceb73
Issue #1621 : Overflow should not be possible in listextend()
2017-01-14 06:30:37 +00:00
Victor Stinner
de4ae3d486
Backed out changeset b9c9691c72c5
...
Issue #28858 : The change b9c9691c72c5 introduced a regression. It seems like
_PyObject_CallArg1() uses more stack memory than
PyObject_CallFunctionObjArgs().
2016-12-04 22:59:09 +01:00
Victor Stinner
27580c1fb5
Replace PyObject_CallFunctionObjArgs() with fastcall
...
* 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 .
2016-12-01 14:43:22 +01:00
Benjamin Peterson
2f8bfef158
replace PY_SIZE_MAX with SIZE_MAX
2016-09-07 09:26:18 -07:00
Benjamin Peterson
05448a62ae
merge 3.5
2016-09-06 17:58:44 -07:00
Benjamin Peterson
5a7d923e75
make sure to not call memcpy with a NULL second argument
2016-09-06 17:58:25 -07:00
Mark Dickinson
5d13238f6e
Issue #27662 : don't use PY_SIZE_MAX for overflow checking in List_New. Patch by Xiang Zhang.
2016-08-21 08:55:15 +01:00
Martin Panter
b93d8637a6
Issue #1621 : Avoid signed overflow in list and tuple operations
...
Patch by Xiang Zhang.
2016-07-25 02:39:20 +00:00
Serhiy Storchaka
7e160ce356
Issue #23034 : The output of a special Python build with defined COUNT_ALLOCS,
...
SHOW_ALLOC_COUNT or SHOW_TRACK_COUNT macros is now off by default. It can
be re-enabled using the "-X showalloccount" option. It now outputs to stderr
instead of stdout.
2016-07-03 21:03:53 +03:00
Serhiy Storchaka
f01e408c16
Issue #26200 : Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
...
in places where Py_DECREF was used.
2016-04-10 18:12:01 +03:00
Serhiy Storchaka
ec39756960
Issue #22570 : Renamed Py_SETREF to Py_XSETREF.
2016-04-06 09:50:03 +03:00
Serhiy Storchaka
ab479c49d3
Issue #26494 : Fixed crash on iterating exhausting iterators.
...
Affected classes are generic sequence iterators, iterators of str, bytes,
bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding
views and os.scandir() iterator.
2016-03-30 20:41:15 +03:00
Serhiy Storchaka
fbb1c5ee06
Issue #26494 : Fixed crash on iterating exhausting iterators.
...
Affected classes are generic sequence iterators, iterators of str, bytes,
bytearray, list, tuple, set, frozenset, dict, OrderedDict, corresponding
views and os.scandir() iterator.
2016-03-30 20:40:02 +03:00
Raymond Hettinger
0dceb91866
Tests versus zero are more compact than tests versus -1.
2016-01-25 10:33:30 -08:00
Serhiy Storchaka
1ed017ae92
Issue #20440 : Cleaning up the code by using Py_SETREF and Py_CLEAR.
...
Old code is correct, but with Py_SETREF and Py_CLEAR it can be cleaner.
This patch doesn't fix bugs and hence there is no need to backport it.
2015-12-27 15:51:32 +02:00
Serhiy Storchaka
5c4064e8bd
Issue #25421 : __sizeof__ methods of builtin types now use dynamic basic size.
...
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.
2015-12-19 20:05:25 +02:00
Benjamin Peterson
a30e2256f7
merge 3.4 ( #24044 )
2015-04-23 17:06:45 -04:00
Benjamin Peterson
bd91ee9cd7
merge 3.3 ( #24044 )
2015-04-23 17:06:33 -04:00
Benjamin Peterson
51454a62e2
merge 3.2 ( #24044 )
2015-04-23 17:05:07 -04:00
Benjamin Peterson
0823ffb2fb
properly handle malloc failure ( closes #24044 )
...
Patch by Christian Heimes.
2015-04-23 17:04:36 -04:00
Benjamin Peterson
c8fd9ce73d
merge 3.4 ( #23515 )
2015-02-25 10:16:56 -05:00
Benjamin Peterson
b808d590a2
fix merge_collapse to actually maintain the invariant it purports to ( closes #23515 )
...
See
de Gouw, Stijn and Rot, Jurriaan and de Boer, Frank S and Bubel, Richard and Hähnle, Reiner
"OpenJDK’s java.utils.Collection.sort() is broken: The good, the bad and the worst case"
2015-02-25 10:12:26 -05:00
Terry Jan Reedy
ffff1440d1
Issue #22077 : Improve index error messages for bytearrays, bytes, lists, and
...
tuples by adding 'or slices'. Added ', not <typename' for bytearrays.
Original patch by Claudiu Popa.
2014-08-02 01:30:37 -04:00
Benjamin Peterson
af9049ebbc
merge 3.3
2014-03-15 12:21:47 -05:00
Benjamin Peterson
4a42cd48d5
avoid referencing past the bounds of an array
2014-03-15 12:21:28 -05:00
Benjamin Peterson
1aca78da62
merge 3.3
2014-03-14 21:54:41 -05:00
Benjamin Peterson
ef87f8cb57
avoid referencing out-of-bounds memory
2014-03-14 21:54:31 -05:00
Kristján Valur Jónsson
25dded041f
Make the various iterators' "setstate" sliently and consistently clip the
...
index. This avoids the possibility of setting an iterator to an invalid
state.
2014-03-05 13:47:57 +00:00
Kristján Valur Jónsson
c5cc5011ac
Make the various iterators' "setstate" sliently and consistently clip the
...
index. This avoids the possibility of setting an iterator to an invalid
state.
2014-03-05 15:23:07 +00:00
Victor Stinner
35f2803a24
Close #19578 : Fix list_ass_subscript(), handle list_resize() failure
...
Notify the caller of the failure (MemoryError exception).
2013-11-21 12:16:35 +01:00
Victor Stinner
4a58707a34
Add _PyUnicodeWriter_WriteASCIIString() function
2013-11-19 12:54:53 +01:00
Victor Stinner
4d3f109ad3
Issue #19513 : Disable overallocation of the PyUnicodeWriter before the last write
2013-11-19 12:09:00 +01:00
Victor Stinner
b8fb197aa0
Issue #19513 : Simplify list_repr()
2013-11-18 22:15:44 +01:00
Victor Stinner
5c733473f2
Issue #19513 : repr(list) now uses the PyUnicodeWriter API, it is faster than
...
the PyAccu API
2013-11-18 21:11:57 +01:00
Antoine Pitrou
9ed5f27266
Issue #18722 : Remove uses of the "register" keyword in C code.
2013-08-13 20:18:52 +02:00
Victor Stinner
2c40f640d9
Issue #18408 : Fix list_ass_slice(), handle list_resize() failure
...
I tested the patch manually by injecting a fault using gdb: list items are
correctly restored on failure.
2013-07-19 23:06:21 +02:00
Victor Stinner
095d99ffff
Issue #18408 : Fix listpop(), handle list_ass_slice() failure
2013-07-17 21:58:01 +02:00
Victor Stinner
32fd6eab1e
Issue #18408 : Fix list.extend(), handle list_resize() failure
2013-07-16 21:45:58 +02:00
Victor Stinner
b27cd3e5ad
Issue #18408 : Fix list.pop() to handle list_resize() failure (MemoryError).
2013-07-08 22:20:44 +02:00
Victor Stinner
7660b880a5
Issue #9566 : More long/Py_ssize_t fixes in tuple and list iterators (it_index)
2013-06-24 23:59:24 +02:00
Armin Ronacher
aa9a79d279
Issue #16148 : implemented PEP 424
2012-10-06 14:03:24 +02:00
David Malcolm
49526f48fc
Issue #14785 : Add sys._debugmallocstats() to help debug low-level memory allocation issues
2012-06-22 14:55:41 -04:00
Antoine Pitrou
a701388de1
Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include it in the stable ABI.
2012-04-05 00:04:20 +02:00
Kristján Valur Jónsson
31668b8f7a
Issue #14288 : Serialization support for builtin iterators.
2012-04-03 10:49:41 +00:00
Antoine Pitrou
d0acb411ef
Issue #14387 : Do not include accu.h from Python.h.
2012-03-22 14:42:18 +01:00
Antoine Pitrou
0197ff97d0
Issue #14387 : Do not include accu.h from Python.h.
2012-03-22 14:38:16 +01:00
Antoine Pitrou
9a812cbc89
Issue #13389 : Full garbage collection passes now clear the freelists for
...
list and dict objects. They already cleared other freelists in the
interpreter.
2011-11-15 00:00:12 +01:00
Petri Lehtinen
9589ab1745
Revert "Accept None as start and stop parameters for list.index() and tuple.index()"
...
Issue #13340 .
2011-11-06 21:06:10 +02:00
Petri Lehtinen
ebfaabd663
Revert "Accept None as start and stop parameters for list.index() and tuple.index()"
...
Issue #13340 .
2011-11-06 21:02:39 +02:00
Amaury Forgeot d'Arc
864741b2c7
Issue #13350 : Replace most usages of PyUnicode_Format by PyUnicode_FromFormat.
2011-11-06 15:10:48 +01:00
Petri Lehtinen
8e9f6c4251
Accept None as start and stop parameters for list.index() and tuple.index().
...
Closes #13340 .
2011-11-05 23:25:34 +02:00
Petri Lehtinen
c2f0a46111
Accept None as start and stop parameters for list.index() and tuple.index()
...
Closes #13340 .
2011-11-05 23:24:31 +02:00
Georg Brandl
388349add2
Closes #12192 : Document that mutating list methods do not return the instance (original patch by Mike Hoy).
2011-10-08 18:32:40 +02:00
Antoine Pitrou
c61c8d7a5e
Issue #12911 : Fix memory consumption when calculating the repr() of huge tuples or lists.
...
This introduces a small private API for this common pattern.
The issue has been discovered thanks to Martin's huge-mem buildbot.
2011-10-06 19:04:12 +02:00
Antoine Pitrou
eeb7eea1f9
Issue #12911 : Fix memory consumption when calculating the repr() of huge tuples or lists.
...
This introduces a small private API for this common pattern.
The issue has been discovered thanks to Martin's huge-mem buildbot.
2011-10-06 18:57:27 +02:00
Mark Dickinson
c7d93b7614
Issue #1621 : Fix undefined behaviour from signed overflow in datetime module hashes, array and list iterations, and get_integer (stringlib/string_format.h)
2011-09-25 15:34:32 +01:00
Mark Dickinson
8f53d092f2
Merge issue #12973 list_repeat fix.
2011-09-19 19:19:50 +01:00
Mark Dickinson
c0420fd42a
Issue #12973 : Fix undefined-behaviour-inducing overflow check in list_repeat.
2011-09-19 19:18:37 +01:00
Brian Curtin
dfc80e3d97
Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
...
The macro was introduced in #12724 .
2011-08-10 20:28:54 -05:00
Daniel Stutzbach
eda70b81d3
#11335 : Fix memory leak after key function failure in sort
2011-05-04 12:46:28 -07:00
Ezio Melotti
3b3499ba69
#11565 : Merge with 3.1.
2011-03-16 11:35:38 +02:00
Ezio Melotti
13925008dc
#11565 : Fix several typos. Patch by Piotr Kasprzyk.
2011-03-16 11:05:33 +02:00
Ezio Melotti
b88ed1549e
#11565 : Merge with 3.2.
2011-03-16 11:38:59 +02:00
Daniel Stutzbach
8eda5f7cd9
#11335 : Fix memory leak when a sort key function throws an exception
2011-03-02 23:37:50 +00:00
Eli Bendersky
cbbaa96036
Issue #10516 : adding list.clear() and list.copy() methods
2011-02-25 05:47:53 +00:00
Victor Stinner
0fcab4a3ed
Issue #9566 : use Py_ssize_t instead of int
2011-01-04 12:59:15 +00:00
Martin v. Löwis
4d0d471a80
Merge branches/pep-0384.
2010-12-03 20:14:31 +00:00
Benjamin Peterson
9efdccae25
code style
2010-12-03 01:44:10 +00:00
Daniel Stutzbach
98338227a7
Issue9915: speeding up sorting with a key
2010-12-02 21:55:33 +00:00
Georg Brandl
00da4e0b5a
Remove unneeded casts to hashfunc.
2010-10-18 07:32:48 +00:00
Benjamin Peterson
0538064554
reorder and save a comparison
2010-08-23 19:35:39 +00:00
Antoine Pitrou
7f14f0d8a0
Recorded merge of revisions 81032 via svnmerge from
...
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r81032 | antoine.pitrou | 2010-05-09 17:52:27 +0200 (dim., 09 mai 2010) | 9 lines
Recorded merge of revisions 81029 via svnmerge from
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.
........
................
2010-05-09 16:14:21 +00:00
Antoine Pitrou
f95a1b3c53
Recorded merge of revisions 81029 via svnmerge from
...
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.
........
2010-05-09 15:52:27 +00:00