Message117729
Mark Dickinson <report@bugs.python.org> wrote:
> Whoops; that *was* string to float. How about float to string?
These are the results for format_float_short. The first one is quite funny:
If the control word is left as is (64-bit prec on Linux), _Py_dg_dtoa
apparently requires more iterations (but still produces the correct
result in this case).
import timeit
s = "str(38210.0)"
t = timeit.Timer(stmt=s)
4.266580820083618
>>> t.timeit(number=10000000)
4.3112568855285645
>>> t.timeit(number=10000000)
4.313380002975464
>>>
3.7413151264190674
>>> t.timeit(number=10000000)
3.7296619415283203
>>> t.timeit(number=10000000)
3.737776041030884
3.756165027618408
>>> t.timeit(number=10000000)
3.775428056716919
>>> t.timeit(number=10000000)
3.775447130203247
In general, execution times for _Py_dg_dtoa vary quite a bit depending on
the number that is converted:
5.097490072250366
2.417008876800537
Judging from these numbers, I think the macros could be called by default without
any real effect on performance. How about setting the rounding mode as well (you
suggested that in #9009)? |
|
Date |
User |
Action |
Args |
2010-09-30 12:11:36 | skrah | set | recipients:
+ skrah, loewis, sjmachin, mark.dickinson, eric.smith, brian.curtin, Kiriakos.Vlahos |
2010-09-30 12:11:35 | skrah | link | issue9980 messages |
2010-09-30 12:11:34 | skrah | create | |
|