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
d9c116ca
Kaydet (Commit)
d9c116ca
authored
Tem 09, 2013
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a spacing saving heuristic to deque's extend methods
üst
bbf8ce5b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
test_deque.py
Lib/test/test_deque.py
+2
-2
_collectionsmodule.c
Modules/_collectionsmodule.c
+16
-0
No files found.
Lib/test/test_deque.py
Dosyayı görüntüle @
d9c116ca
...
...
@@ -543,8 +543,8 @@ class TestBasic(unittest.TestCase):
check
=
self
.
check_sizeof
check
(
deque
(),
basesize
+
blocksize
)
check
(
deque
(
'a'
),
basesize
+
blocksize
)
check
(
deque
(
'a'
*
(
BLOCKLEN
//
2
)),
basesize
+
blocksize
)
check
(
deque
(
'a'
*
(
BLOCKLEN
//
2
+
1
)
),
basesize
+
2
*
blocksize
)
check
(
deque
(
'a'
*
(
BLOCKLEN
-
1
)),
basesize
+
blocksize
)
check
(
deque
(
'a'
*
BLOCKLEN
),
basesize
+
2
*
blocksize
)
check
(
deque
(
'a'
*
(
42
*
BLOCKLEN
)),
basesize
+
43
*
blocksize
)
class
TestVariousIteratorArgs
(
unittest
.
TestCase
):
...
...
Modules/_collectionsmodule.c
Dosyayı görüntüle @
d9c116ca
...
...
@@ -332,6 +332,14 @@ deque_extend(dequeobject *deque, PyObject *iterable)
return
result
;
}
/* Space saving heuristic. Start filling from the left */
if
(
Py_SIZE
(
deque
)
==
0
)
{
assert
(
deque
->
leftblock
==
deque
->
rightblock
);
assert
(
deque
->
leftindex
==
deque
->
rightindex
+
1
);
deque
->
leftindex
=
1
;
deque
->
rightindex
=
0
;
}
it
=
PyObject_GetIter
(
iterable
);
if
(
it
==
NULL
)
return
NULL
;
...
...
@@ -385,6 +393,14 @@ deque_extendleft(dequeobject *deque, PyObject *iterable)
return
result
;
}
/* Space saving heuristic. Start filling from the right */
if
(
Py_SIZE
(
deque
)
==
0
)
{
assert
(
deque
->
leftblock
==
deque
->
rightblock
);
assert
(
deque
->
leftindex
==
deque
->
rightindex
+
1
);
deque
->
leftindex
=
BLOCKLEN
-
1
;
deque
->
rightindex
=
BLOCKLEN
-
2
;
}
it
=
PyObject_GetIter
(
iterable
);
if
(
it
==
NULL
)
return
NULL
;
...
...
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