Commits

Kirill Simonov  committed e67f01a

Optimize slightly the float constructor.

  • Participants
  • Parent commits 1ac3d12

Comments (0)

Files changed (1)

File lib/yaml/constructor.py

 
     def construct_yaml_float(self, node):
         value = str(self.construct_scalar(node))
-        value = value.replace('_', '')
+        value = value.replace('_', '').lower()
         sign = +1
         if value[0] == '-':
             sign = -1
         if value[0] in '+-':
             value = value[1:]
-        if value.lower() == '.inf':
+        if value == '.inf':
             return sign*self.inf_value
-        elif value.lower() == '.nan':
+        elif value == '.nan':
             return self.nan_value
         elif ':' in value:
             digits = [float(part) for part in value.split(':')]