Commit Graph

217 Commits

Author SHA1 Message Date
Serhiy Storchaka d53fe5f407
bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264) 2019-03-13 22:59:55 +02:00
Serhiy Storchaka adfffc7343
Fix the C function signature for _collections._tuplegetter.__reduce__. (GH-12180)
Correctly fixes bpo-36197.
2019-03-05 18:41:09 +02:00
Stéphane Wirtel 359a2f3dab bpo-33012: Fix compilation warnings in memoryobject.c and _collectionsmodule.c (GH-12179)
Cast function pointers to (void(*)(void)) before casting to (PyCFunction)
to make "warning: cast between incompatible function types" false alarm quiet.
2019-03-05 16:10:53 +01:00
Joe Jevnik f36f89257b bpo-36068: Make _tuplegetter objects serializable (GH-11981) 2019-02-21 13:00:40 -08:00
Raymond Hettinger 05f1b93f58
Speed-up argument parsing for common cases in deque.__init__()(GH-11717) 2019-01-31 22:13:43 -08:00
Serhiy Storchaka 052b2dfdc9
bpo-32492: Tweak _collections._tuplegetter. (GH-11367)
* Replace the docstrings cache with sys.intern().
* Improve tests.
* Unify names of tp_descr_get and tp_descr_set functions.
2018-12-31 14:15:16 +02:00
Pablo Galindo 3f5fc70c62 bpo-32492: 1.6x speed up in namedtuple attribute access using C fast-path (#10495)
* bpo-32492: 2.5x speed up in namedtuple attribute access using C fast path

* Add News entry

* fixup! bpo-32492: 2.5x speed up in namedtuple attribute access using C fast path

* Check for tuple in the __get__ of the new descriptor and don't cache the descriptor itself

* Don't inherit from property. Implement GC methods to handle __doc__

* Add a test for the docstring substitution in descriptors

* Update NEWS entry to reflect time against 3.7 branch

* Simplify implementation with argument clinic, better error messages, only __new__

* Use positional-only parameters for the __new__

* Use PyTuple_GET_SIZE and PyTuple_GET_ITEM to tighter the implementation of tuplegetterdescr_get

* Implement __set__ to make tuplegetter a data descriptor

* Use Py_INCREF now that we inline PyTuple_GetItem

* Apply the valid_index() function, saving one test

* Move Py_None test out of the critical path.
2018-12-30 01:24:03 -08:00
Serhiy Storchaka d4f9cf5545
bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
Fix also return type for few other functions (clear, releasebuffer).
2018-11-27 19:34:35 +02:00
Serhiy Storchaka 62be74290a
bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)
Fix invalid function cast warnings with gcc 8
for method conventions different from METH_NOARGS, METH_O and
METH_VARARGS excluding Argument Clinic generated code.
2018-11-27 13:27:31 +02:00
Serhiy Storchaka 81524022d0
bpo-33012: Fix signatures of METH_NOARGS funstions. (GH-10736) 2018-11-27 13:05:02 +02:00
Raymond Hettinger b46ad5431d
Minor performance tweak for deque.index() with a start argument (GH-9440) 2018-09-21 01:46:41 -07:00
Oren Milman 24bd50bdcc closes bpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-3788) 2018-09-11 11:46:55 -07:00
Raymond Hettinger 66953f0ec6
Factor-out two substantially identical code blocks. (GH-8219) 2018-07-10 04:17:40 -07:00
Serhiy Storchaka a5c42284e6
bpo-33677: Fix signatures of tp_clear handlers for AST and deque. (GH-7196) 2018-05-31 07:34:34 +03: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
Serhiy Storchaka f320be77ff bpo-32571: Avoid raising unneeded AttributeError and silencing it in C code (GH-5222)
Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
2018-01-25 17:49:40 +09:00
Serhiy Storchaka a5552f023e
bpo-32240: Add the const qualifier to declarations of PyObject* array arguments. (#4746) 2017-12-15 13:11:11 +02:00
Oren Milman 31aca4bf79 bpo-31586: Use _count_element fast path for real dicts. 2017-09-26 20:18:21 -07:00
Serhiy Storchaka b3a77964ea bpo-27541: Reprs of subclasses of some classes now contain actual type name. (#3631)
Affected classes are bytearray, array, deque, defaultdict, count and repeat.
2017-09-21 14:24:13 +03:00
Raymond Hettinger e1b0287c04 Code clean-up. Remove unnecessary pre-increment before the loop starts. (#3312) 2017-09-04 16:07:06 -07:00
INADA Naoki a6296d34a4 bpo-31095: fix potential crash during GC (GH-2974) 2017-08-24 14:55:17 +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
Serhiy Storchaka d4edfc9abf bpo-29935: Fixed error messages in the index() method of tuple, list and deque (#887)
when pass indices of wrong type.
2017-03-30 18:29:23 +03:00
Serhiy Storchaka ba85d69a3e bpo-29878: Add global instances of int for 0 and 1. (#852) 2017-03-30 09:09:41 +03:00
Louie Lu 357bad7101 bpo-29634: Reduce deque repeat execution when maxlen exist and size is not 1 (#255) (#255) 2017-02-23 22:59:49 -05:00
Victor Stinner dd407d5006 Optimize deque index, insert and rotate() methods
Issue #29452: Use METH_FASTCALL calling convention for index(), insert() and
rotate() methods of collections.deque to avoid the creation a temporary tuple
to pass position arguments. Speedup on deque methods:

* d.rotate(): 1.10x faster
* d.rotate(1): 1.24x faster
* d.insert(): 1.18x faster
* d.index(): 1.24x faster
2017-02-06 16:06:49 +01:00
Raymond Hettinger a24dca6a90 Fix typo 2017-01-12 22:25:25 -08:00
Victor Stinner 7bfb42d5b7 Issue #28858: Remove _PyObject_CallArg1() macro
Replace
   _PyObject_CallArg1(func, arg)
with
   PyObject_CallFunctionObjArgs(func, arg, NULL)

Using the _PyObject_CallArg1() macro increases the usage of the C stack, which
was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this
issue.
2016-12-05 17:04:32 +01:00
Victor Stinner 4778eab1f2 Replace PyObject_CallFunction() with fastcall
Replace
    PyObject_CallFunction(func, "O", arg)
and
    PyObject_CallFunction(func, "O", arg, NULL)
with
    _PyObject_CallArg1(func, arg)

Replace
    PyObject_CallFunction(func, NULL)
with
    _PyObject_CallNoArg(func)

_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.
2016-12-01 14:51:04 +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
Raymond Hettinger 88057171f0 Revert part of 3471a3515827 that caused a performance regression 2016-09-11 22:45:53 -07:00
Victor Stinner ad8c83ad6b Avoid inefficient way to call functions without argument
Don't pass "()" format to PyObject_CallXXX() to call a function without
argument: pass NULL as the format string instead. It avoids to have to parse a
string to produce 0 argument.
2016-09-05 17:53:15 -07:00
doko@ubuntu.com 17f0e61891 - Modules/_collectionsmodule.c: Mark one more internal symbol as static. 2016-06-14 07:27:58 +02:00
doko@ubuntu.com bc7315068f - make some internal symbols static 2016-05-18 01:06:01 +02:00
Serhiy Storchaka a0d416f0d1 Issue #26482: Allowed pickling recursive dequeues. 2016-03-06 08:55:21 +02:00
Raymond Hettinger d79d5b1a50 More logicial order. Move space saving step to just before it is used. 2016-03-04 09:55:07 -08:00
Raymond Hettinger 6f86a3308a Factor-out common subexpression. 2016-03-02 00:30:58 -08:00
Raymond Hettinger 589106b206 Put block length computations in a more logical order. 2016-03-02 00:06:21 -08:00
Raymond Hettinger 38418662e0 Issue #26200: The SETREF macro adds unnecessary work in some cases. 2016-02-08 20:34:49 -08:00
Raymond Hettinger a63897164e merge 2016-02-01 21:21:19 -08:00
Raymond Hettinger 0ef0423cb2 merge 2016-01-26 21:46:03 -08:00
Raymond Hettinger 3743432302 Issue #26194: Fix undefined behavior for deque.insert() when len(d) == maxlen 2016-01-26 21:44:16 -08:00
Raymond Hettinger 306d6b1ea6 Convert another post-decrement while-loop to pre-decrement for consistency
and better generated code (on both GCC and CLang).
2016-01-24 12:40:42 -08:00
Raymond Hettinger 165eee214b Convert two other post-decrement while-loops to pre-decrements for consistency
and for better code generation.
2016-01-24 11:32:07 -08:00
Raymond Hettinger d84ec225bd Miscellaneous refactorings
* Add comment to the maxlen structure entry about the meaning of maxlen == -1
* Factor-out code common to deque_append(left) and deque_extend(left)
* Factor inner-loop in deque_clear() to use only 1 test per loop instead of 2
* Tighten inner-loops for deque_item() and deque_ass_item() so that the
  compiler can combine the decrement and test into a single step.
2016-01-24 09:12:06 -08:00
Benjamin Peterson 3e47a1337c merge 3.5 2016-01-01 11:56:35 -06:00
Benjamin Peterson 4e3dd51396 merge 3.4 2016-01-01 11:56:16 -06:00
Benjamin Peterson 630329e4ea merge 3.3 2016-01-01 11:55:47 -06:00
Benjamin Peterson 0e617e22f0 remove some copyright notices supserseded by the toplevel ones 2016-01-01 11:53:47 -06: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