[Python-checkins] cpython: locale.delocalize(): only call localeconv() once

victor.stinner python-checkins at python.org
Tue Nov 3 08:35:48 EST 2015


https://hg.python.org/cpython/rev/45719f62f3a3
changeset:   98944:45719f62f3a3
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Nov 03 14:34:51 2015 +0100
summary:
  locale.delocalize(): only call localeconv() once

files:
  Lib/locale.py |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Lib/locale.py b/Lib/locale.py
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -303,12 +303,16 @@
 
 def delocalize(string):
     "Parses a string as a normalized number according to the locale settings."
+
+    conv = localeconv()
+
     #First, get rid of the grouping
-    ts = localeconv()['thousands_sep']
+    ts = conv['thousands_sep']
     if ts:
         string = string.replace(ts, '')
+
     #next, replace the decimal point with a dot
-    dd = localeconv()['decimal_point']
+    dd = conv['decimal_point']
     if dd:
         string = string.replace(dd, '.')
     return string

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list