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
aca7f574
Unverified
Kaydet (Commit)
aca7f574
authored
Kas 15, 2017
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Kas 15, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30950: Convert round() to Argument Clinic. (#2740)
üst
00987f62
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
20 deletions
+51
-20
bltinmodule.c
Python/bltinmodule.c
+16
-19
bltinmodule.c.h
Python/clinic/bltinmodule.c.h
+35
-1
No files found.
Python/bltinmodule.c
Dosyayı görüntüle @
aca7f574
...
...
@@ -2079,19 +2079,23 @@ builtin_repr(PyObject *module, PyObject *obj)
}
/* AC: cannot convert yet, as needs PEP 457 group support in inspect
* or a semantic change to accept None for "ndigits"
*/
/*[clinic input]
round as builtin_round
number: object
ndigits: object = NULL
Round a number to a given precision in decimal digits.
The return value is an integer if ndigits is omitted or None. Otherwise
the return value has the same type as the number. ndigits may be negative.
[clinic start generated code]*/
static
PyObject
*
builtin_round
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
builtin_round_impl
(
PyObject
*
module
,
PyObject
*
number
,
PyObject
*
ndigits
)
/*[clinic end generated code: output=ff0d9dd176c02ede input=854bc3a217530c3d]*/
{
PyObject
*
ndigits
=
NULL
;
static
char
*
kwlist
[]
=
{
"number"
,
"ndigits"
,
0
};
PyObject
*
number
,
*
round
,
*
result
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"O|O:round"
,
kwlist
,
&
number
,
&
ndigits
))
return
NULL
;
PyObject
*
round
,
*
result
;
if
(
Py_TYPE
(
number
)
->
tp_dict
==
NULL
)
{
if
(
PyType_Ready
(
Py_TYPE
(
number
))
<
0
)
...
...
@@ -2115,13 +2119,6 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
return
result
;
}
PyDoc_STRVAR
(
round_doc
,
"round(number[, ndigits]) -> number
\n
\
\n
\
Round a number to a given precision in decimal digits (default 0 digits).
\n
\
This returns an int when called with one argument, otherwise the
\n
\
same type as the number. ndigits may be negative."
);
/*AC: we need to keep the kwds dict intact to easily call into the
* list.sort method, which isn't currently supported in AC. So we just use
...
...
@@ -2679,7 +2676,7 @@ static PyMethodDef builtin_methods[] = {
BUILTIN_POW_METHODDEF
{
"print"
,
(
PyCFunction
)
builtin_print
,
METH_FASTCALL
|
METH_KEYWORDS
,
print_doc
},
BUILTIN_REPR_METHODDEF
{
"round"
,
(
PyCFunction
)
builtin_round
,
METH_VARARGS
|
METH_KEYWORDS
,
round_doc
},
BUILTIN_ROUND_METHODDEF
BUILTIN_SETATTR_METHODDEF
BUILTIN_SORTED_METHODDEF
BUILTIN_SUM_METHODDEF
...
...
Python/clinic/bltinmodule.c.h
Dosyayı görüntüle @
aca7f574
...
...
@@ -573,6 +573,40 @@ PyDoc_STRVAR(builtin_repr__doc__,
#define BUILTIN_REPR_METHODDEF \
{"repr", (PyCFunction)builtin_repr, METH_O, builtin_repr__doc__},
PyDoc_STRVAR
(
builtin_round__doc__
,
"round($module, /, number, ndigits=None)
\n
"
"--
\n
"
"
\n
"
"Round a number to a given precision in decimal digits.
\n
"
"
\n
"
"The return value is an integer if ndigits is omitted or None. Otherwise
\n
"
"the return value has the same type as the number. ndigits may be negative."
);
#define BUILTIN_ROUND_METHODDEF \
{"round", (PyCFunction)builtin_round, METH_FASTCALL|METH_KEYWORDS, builtin_round__doc__},
static
PyObject
*
builtin_round_impl
(
PyObject
*
module
,
PyObject
*
number
,
PyObject
*
ndigits
);
static
PyObject
*
builtin_round
(
PyObject
*
module
,
PyObject
**
args
,
Py_ssize_t
nargs
,
PyObject
*
kwnames
)
{
PyObject
*
return_value
=
NULL
;
static
const
char
*
const
_keywords
[]
=
{
"number"
,
"ndigits"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"O|O:round"
,
_keywords
,
0
};
PyObject
*
number
;
PyObject
*
ndigits
=
NULL
;
if
(
!
_PyArg_ParseStackAndKeywords
(
args
,
nargs
,
kwnames
,
&
_parser
,
&
number
,
&
ndigits
))
{
goto
exit
;
}
return_value
=
builtin_round_impl
(
module
,
number
,
ndigits
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
builtin_sum__doc__
,
"sum($module, iterable, start=0, /)
\n
"
"--
\n
"
...
...
@@ -676,4 +710,4 @@ builtin_issubclass(PyObject *module, PyObject **args, Py_ssize_t nargs)
exit:
return
return_value
;
}
/*[clinic end generated code: output=
09752daa8cdd6ec7
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
d46a224ac804eef1
input=a9049054013a1b77]*/
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