Commit graph

419 commits

Author SHA1 Message Date
INADA Naoki 778928b0c7 bpo-29304: Simplify dict lookup functions (GH-2407)
* remove hashpos parameter from lookdict functions.
* remove many duplicated code from lookdict functions.
2017-08-03 23:45:15 +09:00
Serhiy Storchaka 6969eaf468 bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)
the bare METH_FASTCALL be used for functions with positional-only
parameters.
2017-07-03 21:20:15 +03:00
INADA Naoki 870c286e27 bp-29304: Simplify dictobject.c (GH-2347)
replace `(i << 2) + 1` with `i*5`
2017-06-24 09:03:19 +09:00
INADA Naoki 073ae487b3 bpo-29304: simplify lookdict_index() function. (GH-2273) 2017-06-23 15:22:50 +09:00
Serhiy Storchaka 753bca3934 bpo-27945: Fixed various segfaults with dict. (#1657)
Based on patches by Duane Griffin and Tim Mitchell.
2017-05-20 12:30:02 +03:00
T. Wouters a00c3fd12d bpo-29941: Assert fixes (#886)
Make a non-Py_DEBUG, asserts-enabled build of CPython possible. This means
making sure helper functions are defined when NDEBUG is not defined, not
just when Py_DEBUG is defined.

Also fix a division-by-zero in obmalloc.c that went unnoticed because in Py_DEBUG mode, elsize is never zero.
2017-03-31 09:14:41 -07:00
Serhiy Storchaka c61ac1642d Don't use Py_SIZE for dict object. (#747) 2017-03-21 08:52:38 +02:00
INADA Naoki 1b8df107f8 bpo-24274: fix erroneous comment in dictobject.c (GH-196)
lookdict_unicode() and lookdict_unicode_nodummy() may raise exception
when key is not unicode.
2017-02-20 22:48:10 +09:00
INADA Naoki 2294f3aee1 bpo-29438: fixed use-after-free in key sharing dict (#17) 2017-02-12 13:51:30 +09:00
Serhiy Storchaka 19d2597ed5 Issue #29311: Regenerate Argument Clinic. 2017-02-04 08:05:07 +02:00
Serhiy Storchaka 78d9e58f20 Issues #29311, #29289: Fixed and improved docstrings for dict and OrderedDict
methods.
2017-01-25 00:30:04 +02:00
Serhiy Storchaka 48088ee9ba Issue #29311: Argument Clinic generates reasonable name for the parameter "default". 2017-01-19 19:00:30 +02:00
Victor Stinner 91f0d4aa2f Add a note explaining why dict_update() doesn't use METH_FASTCALL
Issue #29312.
2017-01-19 12:45:06 +01:00
Victor Stinner 7dc6a5f50a dict.get() and dict.setdefault() now use AC
Issue #29311: dict.get() and dict.setdefault() methods now use Argument Clinic
to parse arguments. Their calling convention changes from METH_VARARGS to
METH_FASTCALL which avoids the creation of a temporary tuple.

The signature of docstrings is also enhanced. For example,
    get(...)
becomes:
    get(self, key, default=None, /)
2017-01-19 12:37:13 +01:00
Serhiy Storchaka 617c7753ce Issue #28969: Fixed race condition in C implementation of functools.lru_cache.
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
2017-01-12 19:42:20 +02:00
Serhiy Storchaka 42e1ea9a10 Issue #28969: Fixed race condition in C implementation of functools.lru_cache.
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
2017-01-12 19:12:21 +02:00
Serhiy Storchaka 67796521dd Issue #28969: Fixed race condition in C implementation of functools.lru_cache.
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
2017-01-12 18:34:33 +02:00
Antoine Pitrou c06ae208eb Issue #28427: old keys should not remove new values from
WeakValueDictionary when collecting from another thread.
2016-12-27 14:34:54 +01:00
Antoine Pitrou d741ed492f Issue #28427: old keys should not remove new values from
WeakValueDictionary when collecting from another thread.
2016-12-27 14:23:43 +01:00
Antoine Pitrou e10ca3a0fe Issue #28427: old keys should not remove new values from
WeakValueDictionary when collecting from another thread.
2016-12-27 14:19:20 +01:00
INADA Naoki 6165d55f13 Issue #28147: Fix a memory leak in split-table dictionaries
setattr() must not convert combined table into split table.
2016-12-20 09:54:24 +09:00
Victor Stinner 5cc70c9935 Merge 3.6 2016-12-15 17:23:24 +01:00
Victor Stinner 3d3f264849 Fix a memory leak in split-table dictionaries
Issue #28147: Fix a memory leak in split-table dictionaries: setattr() must not
convert combined table into split table.

Patch written by INADA Naoki.
2016-12-15 17:21:23 +01:00
INADA Naoki ba6097734d Issue #28818: Simplify lookdict functions 2016-12-07 20:41:42 +09:00
Victor Stinner a5ed5f000a Use _PyObject_CallNoArg()
Replace:
    PyObject_CallObject(callable, NULL)
with:
    _PyObject_CallNoArg(callable)
2016-12-06 18:45:50 +01: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
INADA Naoki 2c5a830f2a Issue #28731: Optimize _PyDict_NewPresized() to create correct size dict.
Improve speed of dict literal with constant keys up to 30%.
2016-12-07 18:34:44 +09:00
INADA Naoki 92c50eee52 Issue #28731: Optimize _PyDict_NewPresized() to create correct size dict
Improve speed of dict literal with constant keys up to 30%.
2016-11-22 00:57:02 +09:00
Victor Stinner c7a8f67411 Issue #28618: Mark dict lookup functions as hot
It's common to see these functions in the top 3 of "perf report".
2016-11-15 15:13:40 +01:00
Victor Stinner 0cae609847 Use PyThreadState_GET() in performance critical code
It seems like _PyThreadState_UncheckedGet() is not inlined as expected, even
when using gcc -O3.
2016-11-11 01:43:56 +01:00
Serhiy Storchaka f0b311bd73 Issue #28123: _PyDict_GetItem_KnownHash() now can raise an exception as
PyDict_GetItemWithError().  Patch by Xiang Zhang.
2016-11-06 13:18:24 +02:00
INADA Naoki 93f26f794d Issue #28583: PyDict_SetDefault didn't combine split table when needed.
Patch by Xiang Zhang.
2016-11-02 18:45:16 +09:00
Serhiy Storchaka 7f0514ad54 Backed out changeset 6b88dfc7b25d 2016-10-31 20:14:05 +02:00
Serhiy Storchaka e26e20db95 Issue #28199: Microoptimized dict resizing. Based on patch by Naoki Inada. 2016-10-29 10:50:00 +03:00
Serhiy Storchaka 04230c4087 Issue #28123: _PyDict_GetItem_KnownHash() now can raise an exception as
PyDict_GetItemWithError().  Patch by Xiang Zhang.
2016-11-06 13:19:38 +02:00
INADA Naoki ca2d8be4ba Issue #28580: Optimize iterating split table values.
Patch by Xiang Zhang.
2016-11-04 16:59:10 +09:00
INADA Naoki a3498c7569 Issue #28583: PyDict_SetDefault didn't combine split table when needed.
Patch by Xiang Zhang.
2016-11-02 18:47:24 +09:00
Serhiy Storchaka 5e325d9c41 Merge from 3.6. 2016-10-31 20:15:48 +02:00
Serhiy Storchaka 041794908b Issue #28199: Microoptimized dict resizing. Based on patch by Naoki Inada. 2016-10-29 10:50:00 +03:00
Serhiy Storchaka d76d8bfee1 Issue #28199: Microoptimized dict resizing. Based on patch by Naoki Inada. 2016-10-29 10:49:43 +03:00
Yury Selivanov f0bbee6228 Merge 3.6 (issue #28544) 2016-10-28 19:01:46 -04:00
Yury Selivanov 684ef2c888 Issue #28544: Pass PyObject* to _PyDict_Pop, not PyDictObject* 2016-10-28 19:01:21 -04:00
INADA Naoki b574e77122 Issue #28509: dict.update() no longer allocate unnecessary large memory 2016-10-27 19:30:10 +09:00
INADA Naoki b1152be2de Issue #28509: dict.update() no longer allocate unnecessary large memory 2016-10-27 19:26:50 +09:00
Raymond Hettinger b12785d456 Reference the original compact-and-ordered proposal 2016-10-22 09:58:14 -07:00
doko@ubuntu.com de69ee71e2 - dictobject.c: Make dict_merge symbol a static symbol 2016-10-11 08:04:02 +02:00
doko@ubuntu.com c96df68ea3 - dictobject.c: Make dict_merge symbol a static symbol 2016-10-11 08:04:02 +02:00
Serhiy Storchaka 49f5cdde1a Issue #28183: Optimize and cleanup dict iteration. 2016-10-09 23:08:05 +03:00
INADA Naoki 267941c675 Issue #28201: Dict reduces possibility of 2nd conflict in hash table.
Do perturb shift after first conflict.
2016-10-06 15:19:07 +09:00