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
1fc4b776
Kaydet (Commit)
1fc4b776
authored
Mar 04, 2006
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Change some sequnce APIs to use Py_ssize_t.
üst
8c49c828
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
abstract.h
Include/abstract.h
+4
-4
abstract.c
Objects/abstract.c
+9
-5
No files found.
Include/abstract.h
Dosyayı görüntüle @
1fc4b776
...
...
@@ -1042,7 +1042,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* Return a pointer to the underlying item array for
an object retured by PySequence_Fast */
PyAPI_FUNC
(
in
t
)
PySequence_Count
(
PyObject
*
o
,
PyObject
*
value
);
PyAPI_FUNC
(
Py_ssize_
t
)
PySequence_Count
(
PyObject
*
o
,
PyObject
*
value
);
/*
Return the number of occurrences on value on o, that is,
...
...
@@ -1060,8 +1060,8 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
#define PY_ITERSEARCH_COUNT 1
#define PY_ITERSEARCH_INDEX 2
#define PY_ITERSEARCH_CONTAINS 3
PyAPI_FUNC
(
int
)
_PySequence_IterSearch
(
PyObject
*
seq
,
PyObject
*
obj
,
int
operation
);
PyAPI_FUNC
(
Py_ssize_t
)
_PySequence_IterSearch
(
PyObject
*
seq
,
PyObject
*
obj
,
int
operation
);
/*
Iterate over seq. Result depends on the operation:
PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if
...
...
@@ -1086,7 +1086,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
is equivalent to the Python expression: value in o.
*/
PyAPI_FUNC
(
in
t
)
PySequence_Index
(
PyObject
*
o
,
PyObject
*
value
);
PyAPI_FUNC
(
Py_ssize_
t
)
PySequence_Index
(
PyObject
*
o
,
PyObject
*
value
);
/*
Return the first index for which o[i]=value. On error,
...
...
Objects/abstract.c
Dosyayı görüntüle @
1fc4b776
...
...
@@ -1577,10 +1577,10 @@ PySequence_Fast(PyObject *v, const char *m)
set ValueError and return -1 if none found; also return -1 on error.
Py_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on error.
*/
in
t
Py_ssize_
t
_PySequence_IterSearch
(
PyObject
*
seq
,
PyObject
*
obj
,
int
operation
)
{
in
t
n
;
Py_ssize_
t
n
;
int
wrapped
;
/* for PY_ITERSEARCH_INDEX, true iff n wrapped around */
PyObject
*
it
;
/* iter(seq) */
...
...
@@ -1614,6 +1614,7 @@ _PySequence_IterSearch(PyObject *seq, PyObject *obj, int operation)
case
PY_ITERSEARCH_COUNT
:
++
n
;
if
(
n
<=
0
)
{
/* XXX(nnorwitz): int means ssize_t */
PyErr_SetString
(
PyExc_OverflowError
,
"count exceeds C int size"
);
goto
Fail
;
...
...
@@ -1622,6 +1623,7 @@ _PySequence_IterSearch(PyObject *seq, PyObject *obj, int operation)
case
PY_ITERSEARCH_INDEX
:
if
(
wrapped
)
{
/* XXX(nnorwitz): int means ssize_t */
PyErr_SetString
(
PyExc_OverflowError
,
"index exceeds C int size"
);
goto
Fail
;
...
...
@@ -1660,7 +1662,7 @@ Done:
}
/* Return # of times o appears in s. */
in
t
Py_ssize_
t
PySequence_Count
(
PyObject
*
s
,
PyObject
*
o
)
{
return
_PySequence_IterSearch
(
s
,
o
,
PY_ITERSEARCH_COUNT
);
...
...
@@ -1672,12 +1674,14 @@ PySequence_Count(PyObject *s, PyObject *o)
int
PySequence_Contains
(
PyObject
*
seq
,
PyObject
*
ob
)
{
Py_ssize_t
result
;
if
(
PyType_HasFeature
(
seq
->
ob_type
,
Py_TPFLAGS_HAVE_SEQUENCE_IN
))
{
PySequenceMethods
*
sqm
=
seq
->
ob_type
->
tp_as_sequence
;
if
(
sqm
!=
NULL
&&
sqm
->
sq_contains
!=
NULL
)
return
(
*
sqm
->
sq_contains
)(
seq
,
ob
);
}
return
_PySequence_IterSearch
(
seq
,
ob
,
PY_ITERSEARCH_CONTAINS
);
result
=
_PySequence_IterSearch
(
seq
,
ob
,
PY_ITERSEARCH_CONTAINS
);
return
Py_SAFE_DOWNCAST
(
result
,
Py_ssize_t
,
int
);
}
/* Backwards compatibility */
...
...
@@ -1688,7 +1692,7 @@ PySequence_In(PyObject *w, PyObject *v)
return
PySequence_Contains
(
w
,
v
);
}
in
t
Py_ssize_
t
PySequence_Index
(
PyObject
*
s
,
PyObject
*
o
)
{
return
_PySequence_IterSearch
(
s
,
o
,
PY_ITERSEARCH_INDEX
);
...
...
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