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
3a9b062f
Kaydet (Commit)
3a9b062f
authored
Ock 03, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Manually merge r68096,68189 from 3.0 branch.
üst
3f5f8228
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
5 deletions
+19
-5
fractions.py
Lib/fractions.py
+1
-1
heapq.py
Lib/heapq.py
+10
-4
test_fractions.py
Lib/test/test_fractions.py
+2
-0
NEWS
Misc/NEWS
+6
-0
No files found.
Lib/fractions.py
Dosyayı görüntüle @
3a9b062f
...
...
@@ -109,7 +109,7 @@ class Fraction(numbers.Rational):
"""
if
isinstance
(
f
,
numbers
.
Integral
):
f
=
float
(
f
)
return
cls
(
f
)
elif
not
isinstance
(
f
,
float
):
raise
TypeError
(
"
%
s.from_float() only takes floats, not
%
r (
%
s)"
%
(
cls
.
__name__
,
f
,
type
(
f
)
.
__name__
))
...
...
Lib/heapq.py
Dosyayı görüntüle @
3a9b062f
...
...
@@ -354,9 +354,12 @@ def nsmallest(n, iterable, key=None):
Equivalent to: sorted(iterable, key=key)[:n]
"""
if
key
is
None
:
it
=
zip
(
iterable
,
count
())
# decorate
result
=
_nsmallest
(
n
,
it
)
return
list
(
map
(
itemgetter
(
0
),
result
))
# undecorate
in1
,
in2
=
tee
(
iterable
)
keys
=
in1
if
key
is
None
else
map
(
key
,
in1
)
it
=
zip
(
keys
,
count
(),
in2
)
# decorate
it
=
zip
(
map
(
key
,
in1
),
count
(),
in2
)
# decorate
result
=
_nsmallest
(
n
,
it
)
return
list
(
map
(
itemgetter
(
2
),
result
))
# undecorate
...
...
@@ -366,9 +369,12 @@ def nlargest(n, iterable, key=None):
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
"""
if
key
is
None
:
it
=
zip
(
iterable
,
map
(
neg
,
count
()))
# decorate
result
=
_nlargest
(
n
,
it
)
return
list
(
map
(
itemgetter
(
0
),
result
))
# undecorate
in1
,
in2
=
tee
(
iterable
)
keys
=
in1
if
key
is
None
else
map
(
key
,
in1
)
it
=
zip
(
keys
,
map
(
neg
,
count
()),
in2
)
# decorate
it
=
zip
(
map
(
key
,
in1
),
map
(
neg
,
count
()),
in2
)
# decorate
result
=
_nlargest
(
n
,
it
)
return
list
(
map
(
itemgetter
(
2
),
result
))
# undecorate
...
...
Lib/test/test_fractions.py
Dosyayı görüntüle @
3a9b062f
...
...
@@ -136,6 +136,8 @@ class FractionTest(unittest.TestCase):
def
testFromFloat
(
self
):
self
.
assertRaises
(
TypeError
,
F
.
from_float
,
3
+
4
j
)
self
.
assertEquals
((
10
,
1
),
_components
(
F
.
from_float
(
10
)))
bigint
=
1234567890123456789
self
.
assertEquals
((
bigint
,
1
),
_components
(
F
.
from_float
(
bigint
)))
self
.
assertEquals
((
0
,
1
),
_components
(
F
.
from_float
(
-
0.0
)))
self
.
assertEquals
((
10
,
1
),
_components
(
F
.
from_float
(
10.0
)))
self
.
assertEquals
((
-
5
,
2
),
_components
(
F
.
from_float
(
-
2.5
)))
...
...
Misc/NEWS
Dosyayı görüntüle @
3a9b062f
...
...
@@ -92,9 +92,15 @@ Library
- Issue #4796: Added Decimal.from_float() and Context.create_decimal_from_float()
to the decimal module.
- Fractions.from_float() no longer loses precision for integers too big to
cast as floats.
- Issue #4812: add missing underscore prefix to some internal-use-only
constants in the decimal module. (Dec_0 becomes _Dec_0, etc.)
- Issue 4790: The nsmallest() and nlargest() functions in the heapq module
did unnecessary work in the common case where no key function was specified.
- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case
no MSVC compiler is found under Windows. Original patch by Philip Jenvey.
...
...
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