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
909e334e
Kaydet (Commit)
909e334e
authored
Ock 24, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More code cleanup. Remove unnecessary indirection to useless class methods.
üst
31eaafef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
rational.py
Lib/rational.py
+15
-15
No files found.
Lib/rational.py
Dosyayı görüntüle @
909e334e
...
@@ -285,8 +285,9 @@ class Rational(RationalAbc):
...
@@ -285,8 +285,9 @@ class Rational(RationalAbc):
__truediv__
,
__rtruediv__
=
_operator_fallbacks
(
_div
,
operator
.
truediv
)
__truediv__
,
__rtruediv__
=
_operator_fallbacks
(
_div
,
operator
.
truediv
)
__div__
,
__rdiv__
=
_operator_fallbacks
(
_div
,
operator
.
div
)
__div__
,
__rdiv__
=
_operator_fallbacks
(
_div
,
operator
.
div
)
@classmethod
def
__floordiv__
(
a
,
b
):
def
_floordiv
(
cls
,
a
,
b
):
"""a // b"""
# Will be math.floor(a / b) in 3.0.
div
=
a
/
b
div
=
a
/
b
if
isinstance
(
div
,
RationalAbc
):
if
isinstance
(
div
,
RationalAbc
):
# trunc(math.floor(div)) doesn't work if the rational is
# trunc(math.floor(div)) doesn't work if the rational is
...
@@ -296,28 +297,27 @@ class Rational(RationalAbc):
...
@@ -296,28 +297,27 @@ class Rational(RationalAbc):
else
:
else
:
return
math
.
floor
(
div
)
return
math
.
floor
(
div
)
def
__floordiv__
(
a
,
b
):
"""a // b"""
# Will be math.floor(a / b) in 3.0.
return
a
.
_floordiv
(
a
,
b
)
def
__rfloordiv__
(
b
,
a
):
def
__rfloordiv__
(
b
,
a
):
"""a // b"""
"""a // b"""
# Will be math.floor(a / b) in 3.0.
# Will be math.floor(a / b) in 3.0.
return
b
.
_floordiv
(
a
,
b
)
div
=
a
/
b
if
isinstance
(
div
,
RationalAbc
):
@classmethod
# trunc(math.floor(div)) doesn't work if the rational is
def
_mod
(
cls
,
a
,
b
):
# more precise than a float because the intermediate
div
=
a
//
b
# rounding may cross an integer boundary.
return
a
-
b
*
div
return
div
.
numerator
//
div
.
denominator
else
:
return
math
.
floor
(
div
)
def
__mod__
(
a
,
b
):
def
__mod__
(
a
,
b
):
"""a
%
b"""
"""a
%
b"""
return
a
.
_mod
(
a
,
b
)
div
=
a
//
b
return
a
-
b
*
div
def
__rmod__
(
b
,
a
):
def
__rmod__
(
b
,
a
):
"""a
%
b"""
"""a
%
b"""
return
b
.
_mod
(
a
,
b
)
div
=
a
//
b
return
a
-
b
*
div
def
__pow__
(
a
,
b
):
def
__pow__
(
a
,
b
):
"""a ** b
"""a ** b
...
...
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