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
dedf6d68
Kaydet (Commit)
dedf6d68
authored
Eki 09, 1998
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
listextend(): New method which implements L.extend(L2).
üst
e33bba8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
listobject.c
Objects/listobject.c
+74
-0
No files found.
Objects/listobject.c
Dosyayı görüntüle @
dedf6d68
...
...
@@ -568,6 +568,77 @@ listappend(self, args)
return
ins
(
self
,
(
int
)
self
->
ob_size
,
v
);
}
static
PyObject
*
listextend
(
self
,
args
)
PyListObject
*
self
;
PyObject
*
args
;
{
PyObject
*
b
=
NULL
,
*
res
=
NULL
;
PyObject
**
items
;
int
selflen
=
PyList_GET_SIZE
(
self
);
int
blen
;
register
int
i
;
if
(
!
PyArg_ParseTuple
(
args
,
"O"
,
&
b
))
return
NULL
;
if
(
!
PyList_Check
(
b
))
{
PyErr_SetString
(
PyExc_TypeError
,
"list.extend() argument must be a list"
);
return
NULL
;
}
if
(
PyList_GET_SIZE
(
b
)
==
0
)
{
/* short circuit when b is empty */
Py_INCREF
(
Py_None
);
return
Py_None
;
}
if
(
self
==
(
PyListObject
*
)
b
)
{
/* as in list_ass_slice() we must special case the
* situation: a.extend(a)
*
* XXX: I think this way ought to be faster than using
* list_slice() the way list_ass_slice() does.
*/
b
=
PyList_New
(
selflen
);
if
(
!
b
)
return
NULL
;
for
(
i
=
0
;
i
<
selflen
;
i
++
)
{
PyObject
*
o
=
PyList_GET_ITEM
(
self
,
i
);
Py_INCREF
(
o
);
PyList_SET_ITEM
(
b
,
i
,
o
);
}
}
else
/* we want b to have the same refcount semantics for the
* Py_XDECREF() in the finally clause regardless of which
* branch in the above conditional we took.
*/
Py_INCREF
(
b
);
blen
=
PyList_GET_SIZE
(
b
);
/* resize a using idiom */
items
=
self
->
ob_item
;
NRESIZE
(
items
,
PyObject
*
,
selflen
+
blen
);
if
(
items
==
NULL
)
{
PyErr_NoMemory
();
goto
finally
;
}
self
->
ob_item
=
items
;
/* populate the end self with b's items */
for
(
i
=
0
;
i
<
blen
;
i
++
)
{
PyObject
*
o
=
PyList_GET_ITEM
(
b
,
i
);
Py_INCREF
(
o
);
PyList_SET_ITEM
(
self
,
self
->
ob_size
++
,
o
);
}
res
=
Py_None
;
Py_INCREF
(
res
);
finally
:
Py_XDECREF
(
b
);
return
res
;
}
static
PyObject
*
listpop
(
self
,
args
)
PyListObject
*
self
;
...
...
@@ -1309,6 +1380,8 @@ listremove(self, args)
static
char
append_doc
[]
=
"L.append(object) -- append object to end"
;
static
char
extend_doc
[]
=
"L.extend(list) -- extend list by appending list elements"
;
static
char
insert_doc
[]
=
"L.insert(index, object) -- insert object before index"
;
static
char
pop_doc
[]
=
...
...
@@ -1327,6 +1400,7 @@ static char sort_doc[] =
static
PyMethodDef
list_methods
[]
=
{
{
"append"
,
(
PyCFunction
)
listappend
,
0
,
append_doc
},
{
"insert"
,
(
PyCFunction
)
listinsert
,
0
,
insert_doc
},
{
"extend"
,
(
PyCFunction
)
listextend
,
1
,
extend_doc
},
{
"pop"
,
(
PyCFunction
)
listpop
,
1
,
pop_doc
},
{
"remove"
,
(
PyCFunction
)
listremove
,
0
,
remove_doc
},
{
"index"
,
(
PyCFunction
)
listindex
,
0
,
index_doc
},
...
...
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