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
8ca92ae5
Kaydet (Commit)
8ca92ae5
authored
Mar 11, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Eliminate a big block of duplicate code in PySequence_List() by
exposing _PyList_Extend().
üst
97bc6182
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
54 deletions
+13
-54
listobject.h
Include/listobject.h
+1
-0
abstract.c
Objects/abstract.c
+6
-54
listobject.c
Objects/listobject.c
+6
-0
No files found.
Include/listobject.h
Dosyayı görüntüle @
8ca92ae5
...
...
@@ -41,6 +41,7 @@ PyAPI_FUNC(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
PyAPI_FUNC
(
int
)
PyList_Sort
(
PyObject
*
);
PyAPI_FUNC
(
int
)
PyList_Reverse
(
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyList_AsTuple
(
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
_PyList_Extend
(
PyListObject
*
,
PyObject
*
);
/* Macro, trading safety for speed */
#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
...
...
Objects/abstract.c
Dosyayı görüntüle @
8ca92ae5
...
...
@@ -1427,69 +1427,21 @@ Fail:
PyObject
*
PySequence_List
(
PyObject
*
v
)
{
PyObject
*
it
;
/* iter(v) */
PyObject
*
result
;
/* result list */
int
n
;
/* guess for result list size */
int
i
;
PyObject
*
rv
;
/* return value from PyList_Extend */
if
(
v
==
NULL
)
return
null_error
();
/* Special-case list(a_list), for speed. */
if
(
PyList_Check
(
v
))
return
PyList_GetSlice
(
v
,
0
,
PyList_GET_SIZE
(
v
));
/* Get iterator. There may be some low-level efficiency to be gained
* by caching the tp_iternext slot instead of using PyIter_Next()
* later, but premature optimization is the root etc.
*/
it
=
PyObject_GetIter
(
v
);
if
(
it
==
NULL
)
result
=
PyList_New
(
0
);
if
(
result
==
NULL
)
return
NULL
;
/* Guess a result list size. */
n
=
PyObject_Size
(
v
);
if
(
n
<
0
)
{
PyErr_Clear
();
n
=
8
;
/* arbitrary */
}
result
=
PyList_New
(
n
);
if
(
result
==
NULL
)
{
Py_DECREF
(
it
);
rv
=
_PyList_Extend
((
PyListObject
*
)
result
,
v
);
if
(
rv
==
NULL
)
{
Py_DECREF
(
result
);
return
NULL
;
}
/* Run iterator to exhaustion. */
for
(
i
=
0
;
;
i
++
)
{
PyObject
*
item
=
PyIter_Next
(
it
);
if
(
item
==
NULL
)
{
if
(
PyErr_Occurred
())
{
Py_DECREF
(
result
);
result
=
NULL
;
}
break
;
}
if
(
i
<
n
)
PyList_SET_ITEM
(
result
,
i
,
item
);
/* steals ref */
else
{
int
status
=
PyList_Append
(
result
,
item
);
Py_DECREF
(
item
);
/* append creates a new ref */
if
(
status
<
0
)
{
Py_DECREF
(
result
);
result
=
NULL
;
break
;
}
}
}
/* Cut back result list if initial guess was too large. */
if
(
i
<
n
&&
result
!=
NULL
)
{
if
(
PyList_SetSlice
(
result
,
i
,
n
,
(
PyObject
*
)
NULL
)
!=
0
)
{
Py_DECREF
(
result
);
result
=
NULL
;
}
}
Py_DECREF
(
it
);
return
result
;
}
...
...
Objects/listobject.c
Dosyayı görüntüle @
8ca92ae5
...
...
@@ -776,6 +776,12 @@ listextend(PyListObject *self, PyObject *b)
return
NULL
;
}
PyObject
*
_PyList_Extend
(
PyListObject
*
self
,
PyObject
*
b
)
{
return
listextend
(
self
,
b
);
}
static
PyObject
*
list_inplace_concat
(
PyListObject
*
self
,
PyObject
*
other
)
{
...
...
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