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
54023156
Kaydet (Commit)
54023156
authored
Nis 23, 2014
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add implementation notes
üst
b2188630
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
_collectionsmodule.c
Modules/_collectionsmodule.c
+32
-1
No files found.
Modules/_collectionsmodule.c
Dosyayı görüntüle @
54023156
...
...
@@ -3,7 +3,7 @@
/* collections module implementation of a deque() datatype
Written and maintained by Raymond D. Hettinger <python@rcn.com>
Copyright (c) 2004-201
3
Python Software Foundation.
Copyright (c) 2004-201
4
Python Software Foundation.
All rights reserved.
*/
...
...
@@ -145,6 +145,12 @@ typedef struct {
static
PyTypeObject
deque_type
;
/* XXX Todo:
If aligned memory allocations become available, make the
deque object 64 byte aligned so that all of the fields
can be retrieved or updated in a single cache line.
*/
static
PyObject
*
deque_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
...
...
@@ -454,6 +460,31 @@ deque_inplace_concat(dequeobject *deque, PyObject *other)
return
(
PyObject
*
)
deque
;
}
/* The rotate() method is part of the public API and is used internally
as a primitive for other methods.
Rotation by 1 or -1 is a common case, so any optimizations for high
volume rotations should take care not to penalize the common case.
Conceptually, a rotate by one is equivalent to a pop on one side and an
append on the other. However, a pop/append pair is unnecessarily slow
because it requires a incref/decref pair for an object located randomly
in memory. It is better to just move the object pointer from one block
to the next without changing the reference count.
When moving batches of pointers, it is tempting to use memcpy() but that
proved to be slower than a simple loop for a variety of reasons.
Memcpy() cannot know in advance that we're copying pointers instead of
bytes, that the source and destination are pointer aligned and
non-overlapping, that moving just one pointer is a common case, that we
never need to move more than BLOCKLEN pointers, and that at least one
pointer is always moved.
For high volume rotations, newblock() and freeblock() are never called
more than once. Previously emptied blocks are immediately reused as a
destination block. If a block is left-over at the end, it is freed.
*/
static
int
_deque_rotate
(
dequeobject
*
deque
,
Py_ssize_t
n
)
{
...
...
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