mailr17655 - /trunk/compat.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 02, 2012 - 11:39:
Author: bugman
Date: Tue Oct  2 11:39:17 2012
New Revision: 17655

URL: http://svn.gna.org/viewcvs/relax?rev=17655&view=rev
Log:
For running relax with Python 2, the __builtin__.range() function has been 
replaced with xrange.

This causes large speed ups (speed that was lost with the earlier xrange() to 
range() conversions),
and memory decreases.  For example on one system, the system test time 
decreased from 513.029s to
487.586s.


Modified:
    trunk/compat.py

Modified: trunk/compat.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/compat.py?rev=17655&r1=17654&r2=17655&view=diff
==============================================================================
--- trunk/compat.py (original)
+++ trunk/compat.py Tue Oct  2 11:39:17 2012
@@ -28,6 +28,16 @@
 # The Python version.
 py_version = sys.version_info[0]
 
+# Python 2 hacks.
+if py_version == 2:
+    # Python 2 only imports.
+    import __builtin__
+
+    # Switch all range() calls to xrange() for increased speed and memory 
reduction.
+    # This should work as all range() usage for Python 3 in relax must match 
the old xrange() usage.
+    __builtin__.range = __builtin__.xrange
+
+
 # Python 3 work-arounds.
 if py_version == 3:
     # Python 3 only imports.




Related Messages


Powered by MHonArc, Updated Tue Oct 02 12:00:01 2012