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
33fcf9db
Kaydet (Commit)
33fcf9db
authored
Tem 24, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Finish-up the partial conversion from int to Py_ssize_t for deque indices and length.
üst
8c81fdad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
23 deletions
+24
-23
_collectionsmodule.c
Modules/_collectionsmodule.c
+24
-23
No files found.
Modules/_collectionsmodule.c
Dosyayı görüntüle @
33fcf9db
...
...
@@ -52,20 +52,20 @@ typedef struct BLOCK {
}
block
;
#define MAXFREEBLOCKS 10
static
in
t
numfreeblocks
=
0
;
static
Py_ssize_
t
numfreeblocks
=
0
;
static
block
*
freeblocks
[
MAXFREEBLOCKS
];
static
block
*
newblock
(
block
*
leftlink
,
block
*
rightlink
,
in
t
len
)
{
newblock
(
block
*
leftlink
,
block
*
rightlink
,
Py_ssize_
t
len
)
{
block
*
b
;
/* To prevent len from overflowing
IN
T_MAX on 64-bit machines, we
/* 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
IN
T_MAX-2 entries in total.
* have
PY_SSIZE_
T_MAX-2 entries in total.
*/
if
(
len
>=
IN
T_MAX
-
2
*
BLOCKLEN
)
{
if
(
len
>=
PY_SSIZE_
T_MAX
-
2
*
BLOCKLEN
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"cannot add more blocks to the deque"
);
return
NULL
;
...
...
@@ -100,10 +100,10 @@ typedef struct {
PyObject_HEAD
block
*
leftblock
;
block
*
rightblock
;
in
t
leftindex
;
/* in range(BLOCKLEN) */
in
t
rightindex
;
/* in range(BLOCKLEN) */
in
t
len
;
in
t
maxlen
;
Py_ssize_
t
leftindex
;
/* in range(BLOCKLEN) */
Py_ssize_
t
rightindex
;
/* in range(BLOCKLEN) */
Py_ssize_
t
len
;
Py_ssize_
t
maxlen
;
long
state
;
/* incremented whenever the indices move */
PyObject
*
weakreflist
;
/* List of weak references */
}
dequeobject
;
...
...
@@ -355,7 +355,7 @@ PyDoc_STRVAR(extendleft_doc,
static
int
_deque_rotate
(
dequeobject
*
deque
,
Py_ssize_t
n
)
{
in
t
i
,
len
=
deque
->
len
,
halflen
=
(
len
+
1
)
>>
1
;
Py_ssize_
t
i
,
len
=
deque
->
len
,
halflen
=
(
len
+
1
)
>>
1
;
PyObject
*
item
,
*
rv
;
if
(
len
==
0
)
...
...
@@ -392,7 +392,7 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n)
static
PyObject
*
deque_rotate
(
dequeobject
*
deque
,
PyObject
*
args
)
{
in
t
n
=
1
;
Py_ssize_
t
n
=
1
;
if
(
!
PyArg_ParseTuple
(
args
,
"|i:rotate"
,
&
n
))
return
NULL
;
...
...
@@ -462,11 +462,11 @@ deque_clear(dequeobject *deque)
}
static
PyObject
*
deque_item
(
dequeobject
*
deque
,
in
t
i
)
deque_item
(
dequeobject
*
deque
,
Py_ssize_
t
i
)
{
block
*
b
;
PyObject
*
item
;
in
t
n
,
index
=
i
;
Py_ssize_
t
n
,
index
=
i
;
if
(
i
<
0
||
i
>=
deque
->
len
)
{
PyErr_SetString
(
PyExc_IndexError
,
...
...
@@ -591,11 +591,11 @@ deque_traverse(dequeobject *deque, visitproc visit, void *arg)
{
block
*
b
;
PyObject
*
item
;
in
t
index
;
in
t
indexlo
=
deque
->
leftindex
;
Py_ssize_
t
index
;
Py_ssize_
t
indexlo
=
deque
->
leftindex
;
for
(
b
=
deque
->
leftblock
;
b
!=
NULL
;
b
=
b
->
rightlink
)
{
const
in
t
indexhi
=
b
==
deque
->
rightblock
?
const
Py_ssize_
t
indexhi
=
b
==
deque
->
rightblock
?
deque
->
rightindex
:
BLOCKLEN
-
1
;
...
...
@@ -637,12 +637,12 @@ deque_reduce(dequeobject *deque)
if
(
deque
->
maxlen
==
-
1
)
result
=
Py_BuildValue
(
"O(O)"
,
Py_TYPE
(
deque
),
aslist
);
else
result
=
Py_BuildValue
(
"O(O
i
)"
,
Py_TYPE
(
deque
),
aslist
,
deque
->
maxlen
);
result
=
Py_BuildValue
(
"O(O
n
)"
,
Py_TYPE
(
deque
),
aslist
,
deque
->
maxlen
);
}
else
{
if
(
deque
->
maxlen
==
-
1
)
result
=
Py_BuildValue
(
"O(OO)O"
,
Py_TYPE
(
deque
),
aslist
,
Py_None
,
dict
);
else
result
=
Py_BuildValue
(
"O(O
i
)O"
,
Py_TYPE
(
deque
),
aslist
,
deque
->
maxlen
,
dict
);
result
=
Py_BuildValue
(
"O(O
n
)O"
,
Py_TYPE
(
deque
),
aslist
,
deque
->
maxlen
,
dict
);
}
Py_XDECREF
(
dict
);
Py_DECREF
(
aslist
);
...
...
@@ -742,7 +742,8 @@ static PyObject *
deque_richcompare
(
PyObject
*
v
,
PyObject
*
w
,
int
op
)
{
PyObject
*
it1
=
NULL
,
*
it2
=
NULL
,
*
x
,
*
y
;
int
b
,
vs
,
ws
,
cmp
=-
1
;
Py_ssize_t
vs
,
ws
;
int
b
,
cmp
=-
1
;
if
(
!
PyObject_TypeCheck
(
v
,
&
deque_type
)
||
!
PyObject_TypeCheck
(
w
,
&
deque_type
))
{
...
...
@@ -821,13 +822,13 @@ deque_init(dequeobject *deque, PyObject *args, PyObject *kwdargs)
{
PyObject
*
iterable
=
NULL
;
PyObject
*
maxlenobj
=
NULL
;
in
t
maxlen
=
-
1
;
Py_ssize_
t
maxlen
=
-
1
;
char
*
kwlist
[]
=
{
"iterable"
,
"maxlen"
,
0
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwdargs
,
"|OO:deque"
,
kwlist
,
&
iterable
,
&
maxlenobj
))
return
-
1
;
if
(
maxlenobj
!=
NULL
&&
maxlenobj
!=
Py_None
)
{
maxlen
=
PyInt_As
Long
(
maxlenobj
);
maxlen
=
PyInt_As
Ssize_t
(
maxlenobj
);
if
(
maxlen
==
-
1
&&
PyErr_Occurred
())
return
-
1
;
if
(
maxlen
<
0
)
{
...
...
@@ -943,11 +944,11 @@ static PyTypeObject deque_type = {
typedef
struct
{
PyObject_HEAD
in
t
index
;
Py_ssize_
t
index
;
block
*
b
;
dequeobject
*
deque
;
long
state
;
/* state when the iterator is created */
in
t
counter
;
/* number of items remaining for iteration */
Py_ssize_
t
counter
;
/* number of items remaining for iteration */
}
dequeiterobject
;
static
PyTypeObject
dequeiter_type
;
...
...
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