Babel number formatting performance test

18 July 2008
12:05

By cmlenz as Python

Keeping the Locale objects around helps quite a bit

1 import timeit
2 from babel import Locale, numbers
3
4 en_US = Locale.parse('en_US')
5 fr_FR = Locale.parse('en_US')
6 it_IT = Locale.parse('en_US')
7
8 def test():
9 numbers.format_decimal(12345, locale=en_US)
10 numbers.format_scientific(12345, locale=fr_FR)
11 numbers.format_currency(10.12, 'EUR', locale=it_IT)
12
13 t = timeit.Timer("test()", "from __main__ import test")
14 print t.timeit(10000)

Download Raw Source

Comments

No comments so far.