Commits

Victor Stinner  committed e9bc791

sys.version_info

  • Participants
  • Parent commits 9061b49

Comments (0)

Files changed (3)

  - write tests for patch_compile(), ex: ast.literal_ast("1+(2+3j)")
  - optimize using the major Python version? ord("\U0010ffff") for Python 3.3
  - infer type
- - sys.version_info >= (3,3)
- - sys.version_info.major == 2
  - (x * 2) * 3 => x * 6, "fast-math" option?
 
 later:

File astoptimizer/config_pythonbin.py

     config.add_constant('sys.version', sys.version)
     if sys.platform == 'win32':
         config.add_constant('sys.winver', sys.winver)
+    if sys.version_info >= (2, 7):
+        for attr in ('major', 'minor', 'micro', 'releaselevel', 'serial'):
+            value = getattr(sys.version_info, attr)
+            config.add_constant('sys.version_info.%s' % attr, value)
+    else:
+        config.add_constant('sys.version_info', sys.version_info)
+
     config.add_func('platform.python_version',
                     Function(platform.python_version, 0))
     if sys.version_info >= (2, 6):

File astoptimizer/tests.py

         self.assertIn('platform', config.features)
         self.check('sys.hexversion', self.text_num(sys.hexversion), config)
         self.check('sys.version[:3]', self.text_native_str(sys.version[:3]), config)
+
+        if sys.version_info >= (2, 7):
+            self.check_not_optimized('sys.version_info', config)
+            self.check('sys.version_info.minor', self.text_num(sys.version_info.minor), config)
+        else:
+            self.check('sys.version_info', self.text_tuple(*sys.version_info), config)
+
         self.check('platform.python_version()', self.text_native_str(platform.python_version()), config)
         if sys.version_info >= (2, 6):
             self.check('platform.python_version_tuple()', self.text_tuple(*platform.python_version_tuple()), config)