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
c28ad27d
Kaydet (Commit)
c28ad27d
authored
Şub 12, 2009
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 4998: restore utility of __slots__ on Fraction.
(forward merge of r68813).
üst
bc448664
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
numbers.py
Lib/numbers.py
+10
-0
test_fractions.py
Lib/test/test_fractions.py
+5
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/numbers.py
Dosyayı görüntüle @
c28ad27d
...
@@ -15,6 +15,8 @@ class Number(metaclass=ABCMeta):
...
@@ -15,6 +15,8 @@ class Number(metaclass=ABCMeta):
If you just want to check if an argument x is a number, without
If you just want to check if an argument x is a number, without
caring what kind, use isinstance(x, Number).
caring what kind, use isinstance(x, Number).
"""
"""
__slots__
=
()
# Concrete numeric types must provide their own hash implementation
# Concrete numeric types must provide their own hash implementation
__hash__
=
None
__hash__
=
None
...
@@ -38,6 +40,8 @@ class Complex(Number):
...
@@ -38,6 +40,8 @@ class Complex(Number):
type as described below.
type as described below.
"""
"""
__slots__
=
()
@abstractmethod
@abstractmethod
def
__complex__
(
self
):
def
__complex__
(
self
):
"""Return a builtin complex instance. Called for complex(self)."""
"""Return a builtin complex instance. Called for complex(self)."""
...
@@ -152,6 +156,8 @@ class Real(Complex):
...
@@ -152,6 +156,8 @@ class Real(Complex):
Real also provides defaults for the derived operations.
Real also provides defaults for the derived operations.
"""
"""
__slots__
=
()
@abstractmethod
@abstractmethod
def
__float__
(
self
):
def
__float__
(
self
):
"""Any Real can be converted to a native float object.
"""Any Real can be converted to a native float object.
...
@@ -264,6 +270,8 @@ Real.register(float)
...
@@ -264,6 +270,8 @@ Real.register(float)
class
Rational
(
Real
):
class
Rational
(
Real
):
""".numerator and .denominator should be in lowest terms."""
""".numerator and .denominator should be in lowest terms."""
__slots__
=
()
@abstractproperty
@abstractproperty
def
numerator
(
self
):
def
numerator
(
self
):
raise
NotImplementedError
raise
NotImplementedError
...
@@ -287,6 +295,8 @@ class Rational(Real):
...
@@ -287,6 +295,8 @@ class Rational(Real):
class
Integral
(
Rational
):
class
Integral
(
Rational
):
"""Integral adds a conversion to int and the bit-string operations."""
"""Integral adds a conversion to int and the bit-string operations."""
__slots__
=
()
@abstractmethod
@abstractmethod
def
__int__
(
self
):
def
__int__
(
self
):
"""int(self)"""
"""int(self)"""
...
...
Lib/test/test_fractions.py
Dosyayı görüntüle @
c28ad27d
...
@@ -407,6 +407,11 @@ class FractionTest(unittest.TestCase):
...
@@ -407,6 +407,11 @@ class FractionTest(unittest.TestCase):
self
.
assertEqual
(
id
(
r
),
id
(
copy
(
r
)))
self
.
assertEqual
(
id
(
r
),
id
(
copy
(
r
)))
self
.
assertEqual
(
id
(
r
),
id
(
deepcopy
(
r
)))
self
.
assertEqual
(
id
(
r
),
id
(
deepcopy
(
r
)))
def
test_slots
(
self
):
# Issue 4998
r
=
F
(
13
,
7
)
self
.
assertRaises
(
AttributeError
,
setattr
,
r
,
'a'
,
10
)
def
test_main
():
def
test_main
():
run_unittest
(
FractionTest
,
GcdTest
)
run_unittest
(
FractionTest
,
GcdTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
c28ad27d
...
@@ -163,6 +163,10 @@ Core and Builtins
...
@@ -163,6 +163,10 @@ Core and Builtins
Library
Library
-------
-------
- Issue #4998: The memory saving effect of __slots__ had been lost on Fractions
which inherited from numbers.py which did not have __slots__ defined. The
numbers hierarchy now has its own __slots__ declarations.
- Issue #4631: Fix urlopen() result when an HTTP response uses chunked
- Issue #4631: Fix urlopen() result when an HTTP response uses chunked
encoding.
encoding.
...
...
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