summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* merge 3.3 (#20250)Benjamin Peterson2014-01-141-1/+3
|\
| * correct defaultdict signature in docstring (closes #20250)Benjamin Peterson2014-01-141-1/+3
| | | | | | | | Patch from Andrew Barnert.
* | Issue #19512: _count_elements() of _collections reuses PyId_get identifierVictor Stinner2013-11-061-1/+1
| | | | | | | | instead of literal "get" string
* | mergeRaymond Hettinger2013-10-041-14/+15
|\ \ | |/
| * Issue #18594: Make the C code more closely match the pure python code.Raymond Hettinger2013-10-041-14/+15
| |
* | mergeRaymond Hettinger2013-10-021-18/+23
|\ \ | |/
| * Issue #18594: Fix the fallback path in collections.Counter().Raymond Hettinger2013-10-021-18/+23
| |
* | mergeRaymond Hettinger2013-10-011-1/+15
|\ \ | |/
| * Issue #18594: Fix the fast path for collections.Counter().Raymond Hettinger2013-10-011-1/+15
| | | | | | | | The path wasn't being taken due to an over-restrictive type check.
| * Backport deque.rotate() improvements.Raymond Hettinger2013-02-101-19/+73
| |
* | Restore the data block size to 62.Raymond Hettinger2013-07-281-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | The former block size traded away good fit within cache lines in order to gain faster division in deque_item(). However, compilers are getting smarter and can now replace the slow division operation with a fast integer multiply and right shift. Accordingly, it makes sense to go back to a size that lets blocks neatly fill entire cache-lines. GCC-4.8 and CLANG 4.0 both compute "x // 62" with something roughly equivalent to "x * 9520900167075897609 >> 69".
* | Assertions key off NDEBUGRaymond Hettinger2013-07-271-1/+1
| |
* | Minor code simplification by eliminating an unnecessary temporary variable.Raymond Hettinger2013-07-211-12/+6
| |
* | Tweak the deque struct by moving the least used fields (maxlen and weakref) ↵Raymond Hettinger2013-07-141-1/+1
| | | | | | | | to the end.
* | Use a do-while loop in the inner loop for rotate (m is always greater than ↵Raymond Hettinger2013-07-141-2/+6
| | | | | | | | zero).
* | Move the freeblock() call outside the main loop to speed-up and simplify the ↵Raymond Hettinger2013-07-131-9/+15
| | | | | | | | block re-use logic.
* | Add a spacing saving heuristic to deque's extend methodsRaymond Hettinger2013-07-091-0/+16
| |
* | Fix #ifdefRaymond Hettinger2013-07-071-1/+1
| |
* | Use macros for marking and checking endpoints in the doubly-linked list of ↵Raymond Hettinger2013-07-071-47/+81
| | | | | | | | | | | | | | | | | | | | blocks. * Add comment explaining the endpoint checks * Only do the checks in a debug build * Simplify newblock() to only require a length argument and leave the link updates to the calling code. * Also add comment for the freelisting logic.
* | Improve variable names in deque_count()Raymond Hettinger2013-07-071-8/+8
| |
* | Apply the PyObject_VAR_HEAD and Py_SIZE macrosRaymond Hettinger2013-07-061-40/+39
| | | | | | | | to be consistent with practices in other modules.
* | Refactor deque_traverse().Raymond Hettinger2013-07-061-6/+6
| | | | | | | | | | Hoist conditional expression out of the loop. Use rightblock as the guard instead of checking for NULL.
* | Remove unnecessary branches from count() and reverse().Raymond Hettinger2013-07-061-6/+3
| |
* | Speed-up deque indexing by changing the deque block length to a power of two.Raymond Hettinger2013-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The division and modulo calculation in deque_item() can be compiled to fast bitwise operations when the BLOCKLEN is a power of two. Timing before: ~/cpython $ py -m timeit -r7 -s 'from collections import deque' -s 'd=deque(range(10))' 'd[5]' 10000000 loops, best of 7: 0.0627 usec per loop Timing after: ~/cpython $ py -m timeit -r7 -s 'from collections import deque' -s 'd=deque(range(10))' 'd[5]' 10000000 loops, best of 7: 0.0581 usec per loop
* | Misc improvements to collections.deque()Raymond Hettinger2013-06-231-72/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Clarified comment on the impact of BLOCKLEN on deque_index (with a power-of-two, the division and modulo computations are done with a right-shift and bitwise-and). * Clarified comment on the overflow check to note that it is general and not just applicable the 64-bit builds. * In deque._rotate(), the "deque->" indirections are factored-out of the loop (loop invariant code motion), leaving the code cleaner looking and slightly faster. * In deque._rotate(), replaced the memcpy() with an equivalent loop. That saved the memcpy setup time and allowed the pointers to move in their natural leftward and rightward directions. See comparative timings at: http://pastebin.com/p0RJnT5N
* | Minor tweaks to varnames, declarations, and comments.Raymond Hettinger2013-02-071-8/+7
| |
* | Minor variable access clean-ups for deque.rotate().Raymond Hettinger2013-02-051-13/+13
| |
* | Minor edits: Tighten-up the halflen logic and touch-up the assertions and ↵Raymond Hettinger2013-02-041-10/+6
| | | | | | | | comments.
* | Issue 16398: One more assertion for good measure.Raymond Hettinger2013-02-021-0/+2
| |
* | Issue 16398: Add assertions to show why memcmp is safe.Raymond Hettinger2013-02-021-1/+4
| |
* | Issue 16398: Use memcpy() in deque.rotate().Raymond Hettinger2013-02-021-50/+60
| |
* | merge 3.3Benjamin Peterson2013-01-131-6/+2
|\ \ | |/
| * make deque_clear void, since it's infallibleBenjamin Peterson2013-01-131-6/+2
| |
* | Issue #16398: Optimize deque.rotate()Raymond Hettinger2013-01-121-14/+58
|/
* Merge: fix docstring for deque ctor to mark iterable parameter optionalAndrew Svetlov2012-10-311-1/+1
|\
| * Fix docstring for deque ctor to mark iterable parameter optionalAndrew Svetlov2012-10-311-1/+1
| |
* | MERGE: Closes #15469: Correct __sizeof__ support for dequeJesus Cea2012-08-031-1/+20
|\ \ | |/
| * Closes #15469: Correct __sizeof__ support for dequeJesus Cea2012-08-031-1/+20
| |
* | Issue #14288: Serialization support for builtin iterators.Kristján Valur Jónsson2012-04-031-2/+91
| |
* | Issue #13015: Fix a possible reference leak in defaultdict.__repr__.Antoine Pitrou2012-02-151-1/+3
|\ \ | |/ | | | | Patch by Suman Saha.
| * Issue #13015: Fix a possible reference leak in defaultdict.__repr__.Antoine Pitrou2012-02-151-1/+3
| | | | | | | | Patch by Suman Saha.
* | Rename _Py_identifier to _Py_IDENTIFIER.Martin v. Löwis2011-10-141-2/+2
| |
* | Use identifier API for PyObject_GetAttrString.Martin v. Löwis2011-10-101-1/+2
| |
* | Add API for static strings, primarily good for identifiers.Martin v. Löwis2011-10-091-1/+3
| | | | | | | | Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
* | Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.Brian Curtin2011-08-111-2/+1
| | | | | | | | The macro was introduced in #12724.
* | Simplify _count_elements() in _collectionsVictor Stinner2011-04-201-12/+4
|/ | | | PyIter_Next() cannot return a PyExc_StopIteration: it clears this exception.
* Issue 11713: clarify docstring for collections.deque()Raymond Hettinger2011-03-301-1/+1
|
* Issue #11004: Repair edge case in deque.count().Raymond Hettinger2011-01-251-4/+7
| | | | | | | | | (Reviewed by Georg Brandl.) Also made similar changes to deque.reverse() though this wasn't strictly necessary (the edge case cannot occur with two pointers moving to meet in the middle). Making the change in reverse() was more a matter of future-proofing.
* Make C helper function more closely match the pure python version, and add ↵Raymond Hettinger2011-01-031-22/+49
| | | | tests.
* Issue 10667: Fast path for collections.CounterRaymond Hettinger2010-12-151-1/+67
|