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
46334cda
Kaydet (Commit)
46334cda
authored
Agu 01, 2007
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Kill div, mod and divmod on complex (already deprecated in 2.x).
Add docstring for conjugate(). Patch by Jeffrey Yasskin.
üst
b31339fa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
55 deletions
+15
-55
complexobject.c
Objects/complexobject.c
+15
-55
No files found.
Objects/complexobject.c
Dosyayı görüntüle @
46334cda
...
@@ -466,57 +466,18 @@ complex_div(PyObject *v, PyObject *w)
...
@@ -466,57 +466,18 @@ complex_div(PyObject *v, PyObject *w)
static
PyObject
*
static
PyObject
*
complex_remainder
(
PyObject
*
v
,
PyObject
*
w
)
complex_remainder
(
PyObject
*
v
,
PyObject
*
w
)
{
{
Py_complex
div
,
mod
;
PyErr_SetString
(
PyExc_TypeError
,
Py_complex
a
,
b
;
"can't mod complex numbers."
);
TO_COMPLEX
(
v
,
a
);
return
NULL
;
TO_COMPLEX
(
w
,
b
);
if
(
PyErr_Warn
(
PyExc_DeprecationWarning
,
"complex divmod(), // and % are deprecated"
)
<
0
)
return
NULL
;
errno
=
0
;
div
=
c_quot
(
a
,
b
);
/* The raw divisor value. */
if
(
errno
==
EDOM
)
{
PyErr_SetString
(
PyExc_ZeroDivisionError
,
"complex remainder"
);
return
NULL
;
}
div
.
real
=
floor
(
div
.
real
);
/* Use the floor of the real part. */
div
.
imag
=
0
.
0
;
mod
=
c_diff
(
a
,
c_prod
(
b
,
div
));
return
PyComplex_FromCComplex
(
mod
);
}
}
static
PyObject
*
static
PyObject
*
complex_divmod
(
PyObject
*
v
,
PyObject
*
w
)
complex_divmod
(
PyObject
*
v
,
PyObject
*
w
)
{
{
Py_complex
div
,
mod
;
PyErr_SetString
(
PyExc_TypeError
,
PyObject
*
d
,
*
m
,
*
z
;
"can't take floor or mod of complex number."
);
Py_complex
a
,
b
;
return
NULL
;
TO_COMPLEX
(
v
,
a
);
TO_COMPLEX
(
w
,
b
);
if
(
PyErr_Warn
(
PyExc_DeprecationWarning
,
"complex divmod(), // and % are deprecated"
)
<
0
)
return
NULL
;
errno
=
0
;
div
=
c_quot
(
a
,
b
);
/* The raw divisor value. */
if
(
errno
==
EDOM
)
{
PyErr_SetString
(
PyExc_ZeroDivisionError
,
"complex divmod()"
);
return
NULL
;
}
div
.
real
=
floor
(
div
.
real
);
/* Use the floor of the real part. */
div
.
imag
=
0
.
0
;
mod
=
c_diff
(
a
,
c_prod
(
b
,
div
));
d
=
PyComplex_FromCComplex
(
div
);
m
=
PyComplex_FromCComplex
(
mod
);
z
=
PyTuple_Pack
(
2
,
d
,
m
);
Py_XDECREF
(
d
);
Py_XDECREF
(
m
);
return
z
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -560,15 +521,8 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z)
...
@@ -560,15 +521,8 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z)
static
PyObject
*
static
PyObject
*
complex_int_div
(
PyObject
*
v
,
PyObject
*
w
)
complex_int_div
(
PyObject
*
v
,
PyObject
*
w
)
{
{
PyObject
*
t
,
*
r
;
PyErr_SetString
(
PyExc_TypeError
,
"can't take floor of complex number."
);
t
=
complex_divmod
(
v
,
w
);
if
(
t
!=
NULL
)
{
r
=
PyTuple_GET_ITEM
(
t
,
0
);
Py_INCREF
(
r
);
Py_DECREF
(
t
);
return
r
;
}
return
NULL
;
return
NULL
;
}
}
...
@@ -665,6 +619,11 @@ complex_conjugate(PyObject *self)
...
@@ -665,6 +619,11 @@ complex_conjugate(PyObject *self)
return
PyComplex_FromCComplex
(
c
);
return
PyComplex_FromCComplex
(
c
);
}
}
PyDoc_STRVAR
(
complex_conjugate_doc
,
"complex.conjugate() -> complex
\n
"
"
\n
"
"Returns the complex conjugate of its argument. (3-4j).conjugate() == 3+4j."
);
static
PyObject
*
static
PyObject
*
complex_getnewargs
(
PyComplexObject
*
v
)
complex_getnewargs
(
PyComplexObject
*
v
)
{
{
...
@@ -672,7 +631,8 @@ complex_getnewargs(PyComplexObject *v)
...
@@ -672,7 +631,8 @@ complex_getnewargs(PyComplexObject *v)
}
}
static
PyMethodDef
complex_methods
[]
=
{
static
PyMethodDef
complex_methods
[]
=
{
{
"conjugate"
,
(
PyCFunction
)
complex_conjugate
,
METH_NOARGS
},
{
"conjugate"
,
(
PyCFunction
)
complex_conjugate
,
METH_NOARGS
,
complex_conjugate_doc
},
{
"__getnewargs__"
,
(
PyCFunction
)
complex_getnewargs
,
METH_NOARGS
},
{
"__getnewargs__"
,
(
PyCFunction
)
complex_getnewargs
,
METH_NOARGS
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
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