52 Commits

Author SHA1 Message Date
Victor Stinner
c45dbe93b7 bpo-41078: Add pycore_list.h internal header file (GH-21057)
* Move _PyList_ITEMS() to pycore_list.h.
* The C extension "_heapq" is now built with Py_BUILD_CORE_MODULE
  macro defined to access the internal C API.
2020-06-22 17:39:32 +02:00
Raymond Hettinger
0226f3eba0 Let the argument clinic do the type checking for heapq (GH-20284) 2020-05-22 07:28:57 -07:00
Dong-hee Na
4657a8a0d0 bpo-1635741: Port _heapq module to multiphase initialization (GH19057) 2020-03-18 15:29:34 +01:00
Pablo Galindo
79f89e6e5a bpo-39421: Fix posible crash in heapq with custom comparison operators (GH-18118)
* bpo-39421: Fix posible crash in heapq with custom comparison operators

* fixup! bpo-39421: Fix posible crash in heapq with custom comparison operators

* fixup! fixup! bpo-39421: Fix posible crash in heapq with custom comparison operators
2020-01-23 14:07:05 +00:00
Pablo Galindo
e2f48bf0e8 bpo-34797: Convert heapq to the argument clinic (GH-9560) 2018-09-28 12:39:43 -07:00
Martin Panter
cda80940ed Issue #15984: Merge PyUnicode doc from 3.5 2016-04-15 02:27:11 +00:00
Martin Panter
6245cb3c01 Correct “an” → “a” with “Unicode”, “user”, “UTF”, etc
This affects documentation, code comments, and a debugging messages.
2016-04-15 02:14:19 +00:00
Raymond Hettinger
2300bf29e6 Only update the arr variable when PyObject_RichCompareBool() has been called. 2015-12-07 20:45:16 -08:00
Raymond Hettinger
cfe5b6ca04 Divisions-by-two for a positive Py_ssize_t compile more cleanly with >>1 than /2. 2015-07-20 00:25:50 -04:00
Raymond Hettinger
5cbd8331ff Issue #24221: Small optimizations for heapq.
Replaces the PyList_GET_ITEM and PyList_SET_ITEM macros with normal array
accesses.  Replace the siftup unpredicatable branch with arithmetic.
Replace the rc == -1 tests with rc < 0.  Gives nicer looking assembly
with both Clang and GCC-4.9.  Also gives a small performance both for both.
2015-05-22 00:41:57 -07:00
Raymond Hettinger
c784c6db60 Tighten-up code by eliminating an unnecessary variable. 2015-05-15 21:01:13 -07:00
Raymond Hettinger
d69755d1a3 Minor code clean-up. 2015-05-15 17:53:52 -07:00
Raymond Hettinger
636488043b More timings suggest that 2500 is closer to the break-even point. 2015-05-12 21:40:50 -07:00
Raymond Hettinger
4e6bf4b3da merge 2015-05-11 19:59:21 -07:00
Raymond Hettinger
b9db9e152f Defend against a mutation during comparison 2015-05-11 19:58:56 -07:00
Raymond Hettinger
99bf9a2567 Minor code cleanups. 2015-05-11 19:25:32 -07:00
Raymond Hettinger
a032e46df6 Minor stylistic clean-up. 2015-05-11 10:32:57 -07:00
Raymond Hettinger
bc33e57d56 Issue #24155: Optimize heapify for better cache utililzation. 2015-05-11 10:19:03 -07:00
Raymond Hettinger
1dd8e71eb3 Issues #24099, #24100, and #24101: Fix free-after-use bug in heapq. 2015-05-02 10:00:22 -07:00
Raymond Hettinger
48f68d00b8 Factor common code into internal functions.
Clean-up names of static functions.
Use Py_RETURN_NONE macro.
Expose private functions needed to support merge().
Move C imports to the bottom of the Python file.
2014-06-14 16:43:35 -07:00
Raymond Hettinger
234fb2d503 Issue 21424: Apply the nlargest() optimizations to nsmallest() as well. 2014-05-11 14:21:23 -07:00
Raymond Hettinger
277842eff1 Issue #21424: Optimize heaqp.nlargest() to make fewer tuple comparisons.
Consolidates the logic for nlargest() into a single function so that
decoration tuples (elem,order) or (key, order, elem) only need to
be formed when a new element is added to the heap.  Formerly, a tuple
was created for every element regardless of whether it was added to
the heap.

The change reduces the number of tuples created, the number of ordering
integers created, and total number of tuple comparisons.
2014-05-11 01:55:46 -07:00
Raymond Hettinger
90e9338383 Neaten-up a bit add add missing size change check. 2014-05-03 18:45:54 -07:00
Raymond Hettinger
871620d951 Simplify and speedup the internals of the heapq module. 2014-05-03 18:36:48 -07:00
Raymond Hettinger
c9926088dd Issue 21375: Fix possible Py_ssizet overflow in heapq. 2014-05-03 15:22:07 -07:00