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
08336e30
Kaydet (Commit)
08336e30
authored
Agu 18, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
follup to #3473: don't duplicate the reduce code
üst
8692c79b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
56 deletions
+10
-56
bltinmodule.c
Python/bltinmodule.c
+10
-56
No files found.
Python/bltinmodule.c
Dosyayı görüntüle @
08336e30
...
@@ -2001,68 +2001,22 @@ is printed without a trailing newline before reading.");
...
@@ -2001,68 +2001,22 @@ is printed without a trailing newline before reading.");
static
PyObject
*
static
PyObject
*
builtin_reduce
(
PyObject
*
self
,
PyObject
*
args
)
builtin_reduce
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
seq
,
*
func
,
*
result
=
NULL
,
*
it
;
static
PyObject
*
functools_reduce
=
NULL
;
if
(
PyErr_WarnPy3k
(
"reduce() not supported in 3.x; "
if
(
PyErr_WarnPy3k
(
"reduce() not supported in 3.x; "
"use functools.reduce()"
,
1
)
<
0
)
"use functools.reduce()"
,
1
)
<
0
)
return
NULL
;
return
NULL
;
if
(
!
PyArg_UnpackTuple
(
args
,
"reduce"
,
2
,
3
,
&
func
,
&
seq
,
&
result
))
if
(
functools_reduce
==
NULL
)
{
return
NULL
;
PyObject
*
functools
=
PyImport_ImportModule
(
"functools"
);
if
(
result
!=
NULL
)
if
(
functools
==
NULL
)
Py_INCREF
(
result
);
return
NULL
;
functools_reduce
=
PyObject_GetAttrString
(
functools
,
"reduce"
);
it
=
PyObject_GetIter
(
seq
);
Py_DECREF
(
functools
);
if
(
it
==
NULL
)
{
if
(
functools_reduce
==
NULL
)
PyErr_SetString
(
PyExc_TypeError
,
return
NULL
;
"reduce() arg 2 must support iteration"
);
Py_XDECREF
(
result
);
return
NULL
;
}
if
((
args
=
PyTuple_New
(
2
))
==
NULL
)
goto
Fail
;
for
(;;)
{
PyObject
*
op2
;
if
(
args
->
ob_refcnt
>
1
)
{
Py_DECREF
(
args
);
if
((
args
=
PyTuple_New
(
2
))
==
NULL
)
goto
Fail
;
}
op2
=
PyIter_Next
(
it
);
if
(
op2
==
NULL
)
{
if
(
PyErr_Occurred
())
goto
Fail
;
break
;
}
if
(
result
==
NULL
)
result
=
op2
;
else
{
PyTuple_SetItem
(
args
,
0
,
result
);
PyTuple_SetItem
(
args
,
1
,
op2
);
if
((
result
=
PyEval_CallObject
(
func
,
args
))
==
NULL
)
goto
Fail
;
}
}
}
return
PyObject_Call
(
functools_reduce
,
args
,
NULL
);
Py_DECREF
(
args
);
if
(
result
==
NULL
)
PyErr_SetString
(
PyExc_TypeError
,
"reduce() of empty sequence with no initial value"
);
Py_DECREF
(
it
);
return
result
;
Fail:
Py_XDECREF
(
args
);
Py_XDECREF
(
result
);
Py_DECREF
(
it
);
return
NULL
;
}
}
PyDoc_STRVAR
(
reduce_doc
,
PyDoc_STRVAR
(
reduce_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