cpython: 5accb0ac8bfb (original) (raw)
Mercurial > cpython
changeset 84116:5accb0ac8bfb 2.7
Fix comment blocks. Adjust blocksize to a power-of-two for better divmod computations.
Raymond Hettinger python@rcn.com | |
---|---|
date | Fri, 14 Jun 2013 01:06:33 -0400 |
parents | ca8e86711403 |
children | aff0bdab358e |
files | Lib/test/test_deque.py Modules/_collectionsmodule.c |
diffstat | 2 files changed, 8 insertions(+), 12 deletions(-)[+] [-] Lib/test/test_deque.py 2 Modules/_collectionsmodule.c 18 |
line wrap: on
line diff
--- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -522,7 +522,7 @@ class TestBasic(unittest.TestCase): @test_support.cpython_only def test_sizeof(self):
BLOCKLEN = 62[](#l1.7)
BLOCKLEN = 64[](#l1.8) basesize = test_support.calcobjsize('2P4PlP')[](#l1.9) blocksize = struct.calcsize('2P%dP' % BLOCKLEN)[](#l1.10) self.assertEqual(object.__sizeof__(deque()), basesize)[](#l1.11)
--- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -8,12 +8,13 @@ / / The block length may be set to any number over 1. Larger numbers
#define CENTER ((BLOCKLEN - 1) / 2)
/* A dequeobject
is composed of a doubly-linked list of block
nodes.
@@ -58,13 +59,8 @@ static block *freeblocks[MAXFREEBLOCKS];
static block *
newblock(block *leftlink, block *rightlink, Py_ssize_t len) {
block *b;
- /* To prevent len from overflowing PY_SSIZE_T_MAX on 64-bit machines, we
* refuse to allocate new blocks if the current len is dangerously[](#l2.26)
* close. There is some extra margin to prevent spurious arithmetic[](#l2.27)
* overflows at various places. The following check ensures that[](#l2.28)
* the blocks allocated to the deque, in the worst case, can only[](#l2.29)
* have PY_SSIZE_T_MAX-2 entries in total.[](#l2.30)
*/[](#l2.31)