Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
227f0fae
Kaydet (Commit)
227f0fae
authored
Haz 25, 2013
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
reapply 5accb0ac8bfb
üst
3968e299
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
test_deque.py
Lib/test/test_deque.py
+1
-1
_collectionsmodule.c
Modules/_collectionsmodule.c
+7
-11
No files found.
Lib/test/test_deque.py
Dosyayı görüntüle @
227f0fae
...
...
@@ -522,7 +522,7 @@ class TestBasic(unittest.TestCase):
@test_support.cpython_only
def
test_sizeof
(
self
):
BLOCKLEN
=
6
2
BLOCKLEN
=
6
4
basesize
=
test_support
.
calcobjsize
(
'2P4PlP'
)
blocksize
=
struct
.
calcsize
(
'2P
%
dP'
%
BLOCKLEN
)
self
.
assertEqual
(
object
.
__sizeof__
(
deque
()),
basesize
)
...
...
Modules/_collectionsmodule.c
Dosyayı görüntüle @
227f0fae
...
...
@@ -8,12 +8,13 @@
*/
/* The block length may be set to any number over 1. Larger numbers
* reduce the number of calls to the memory allocator but take more
* memory. Ideally, BLOCKLEN should be set with an eye to the
* length of a cache line.
* reduce the number of calls to the memory allocator, give faster
* indexing and rotation, and reduce the link::data overhead ratio.
* Ideally, the block length should be a power-of-two for faster
* division/modulo computations during indexing.
*/
#define BLOCKLEN 6
2
#define BLOCKLEN 6
4
#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
* close. There is some extra margin to prevent spurious arithmetic
* overflows at various places. The following check ensures that
* the blocks allocated to the deque, in the worst case, can only
* have PY_SSIZE_T_MAX-2 entries in total.
*/
/* To prevent len from overflowing PY_SSIZE_T_MAX on 32-bit machines, we
* refuse to allocate new blocks if the current len is nearing overflow. */
if
(
len
>=
PY_SSIZE_T_MAX
-
2
*
BLOCKLEN
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"cannot add more blocks to the deque"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment