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
f28fa663
Kaydet (Commit)
f28fa663
authored
May 30, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #5633: Fixed timeit when the statement is a string and the setup is not.
üst
fa494fd8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
test_timeit.py
Lib/test/test_timeit.py
+7
-0
timeit.py
Lib/timeit.py
+4
-3
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_timeit.py
Dosyayı görüntüle @
f28fa663
...
@@ -124,6 +124,9 @@ class TestTimeit(unittest.TestCase):
...
@@ -124,6 +124,9 @@ class TestTimeit(unittest.TestCase):
def
test_timeit_callable_stmt
(
self
):
def
test_timeit_callable_stmt
(
self
):
self
.
timeit
(
self
.
fake_callable_stmt
,
self
.
fake_setup
,
number
=
3
)
self
.
timeit
(
self
.
fake_callable_stmt
,
self
.
fake_setup
,
number
=
3
)
def
test_timeit_callable_setup
(
self
):
self
.
timeit
(
self
.
fake_stmt
,
self
.
fake_callable_setup
,
number
=
3
)
def
test_timeit_callable_stmt_and_setup
(
self
):
def
test_timeit_callable_stmt_and_setup
(
self
):
self
.
timeit
(
self
.
fake_callable_stmt
,
self
.
timeit
(
self
.
fake_callable_stmt
,
self
.
fake_callable_setup
,
number
=
3
)
self
.
fake_callable_setup
,
number
=
3
)
...
@@ -173,6 +176,10 @@ class TestTimeit(unittest.TestCase):
...
@@ -173,6 +176,10 @@ class TestTimeit(unittest.TestCase):
self
.
repeat
(
self
.
fake_callable_stmt
,
self
.
fake_setup
,
self
.
repeat
(
self
.
fake_callable_stmt
,
self
.
fake_setup
,
repeat
=
3
,
number
=
5
)
repeat
=
3
,
number
=
5
)
def
test_repeat_callable_setup
(
self
):
self
.
repeat
(
self
.
fake_stmt
,
self
.
fake_callable_setup
,
repeat
=
3
,
number
=
5
)
def
test_repeat_callable_stmt_and_setup
(
self
):
def
test_repeat_callable_stmt_and_setup
(
self
):
self
.
repeat
(
self
.
fake_callable_stmt
,
self
.
fake_callable_setup
,
self
.
repeat
(
self
.
fake_callable_stmt
,
self
.
fake_callable_setup
,
repeat
=
3
,
number
=
5
)
repeat
=
3
,
number
=
5
)
...
...
Lib/timeit.py
Dosyayı görüntüle @
f28fa663
...
@@ -65,7 +65,7 @@ default_timer = time.perf_counter
...
@@ -65,7 +65,7 @@ default_timer = time.perf_counter
# in Timer.__init__() depend on setup being indented 4 spaces and stmt
# in Timer.__init__() depend on setup being indented 4 spaces and stmt
# being indented 8 spaces.
# being indented 8 spaces.
template
=
"""
template
=
"""
def inner(_it, _timer):
def inner(_it, _timer
{init}
):
{setup}
{setup}
_t0 = _timer()
_t0 = _timer()
for _i in _it:
for _i in _it:
...
@@ -119,9 +119,10 @@ class Timer:
...
@@ -119,9 +119,10 @@ class Timer:
stmt
=
reindent
(
stmt
,
8
)
stmt
=
reindent
(
stmt
,
8
)
if
isinstance
(
setup
,
str
):
if
isinstance
(
setup
,
str
):
setup
=
reindent
(
setup
,
4
)
setup
=
reindent
(
setup
,
4
)
src
=
template
.
format
(
stmt
=
stmt
,
setup
=
setup
)
src
=
template
.
format
(
stmt
=
stmt
,
setup
=
setup
,
init
=
''
)
elif
callable
(
setup
):
elif
callable
(
setup
):
src
=
template
.
format
(
stmt
=
stmt
,
setup
=
'_setup()'
)
src
=
template
.
format
(
stmt
=
stmt
,
setup
=
'_setup()'
,
init
=
', _setup=_setup'
)
ns
[
'_setup'
]
=
setup
ns
[
'_setup'
]
=
setup
else
:
else
:
raise
ValueError
(
"setup is neither a string nor callable"
)
raise
ValueError
(
"setup is neither a string nor callable"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
f28fa663
...
@@ -60,6 +60,8 @@ Core and Builtins
...
@@ -60,6 +60,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #5633: Fixed timeit when the statement is a string and the setup is not.
- Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
- Issue #24326: Fixed audioop.ratecv() with non-default weightB argument.
Original patch by David Moore.
Original patch by David Moore.
...
...
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