Commits

Pierre Carbonnelle committed 063a2e9

Recognize range in python 3.
Fix import issue, again.

Comments (0)

Files changed (4)

pyDatalog/console.py

 """
 import code
 import sys
-import pyDatalog # or from pyDatalog import pyDatalog
-import pyEngine # or from pyDatalog import pyEngine
+from pyDatalog import pyDatalog
+from pyDatalog import pyEngine
 
 pyEngine.Auto_print = True
 

pyDatalog/pyDatalog.py

 import sys
 import weakref
 
-import version
-import pyEngine
-import pyParser
-from pyParser import Symbol, Expression, Lambda, Literal, Body
+try:
+    from . import version
+    from . import pyEngine
+    from . import pyParser
+    from .pyParser import Symbol, Expression, Lambda, Literal, Body
+except ValueError:
+    import version
+    import pyEngine
+    import pyParser
+    from pyParser import Symbol, Expression, Lambda, Literal, Body
     
 print("pyDatalog version %s" % version.__version__)
 

pyDatalog/pyParser.py

 import re
 import string
 import six
-from six.moves import builtins
+from six.moves import builtins, xrange
 import sys
 import weakref
     
     def __init__ (self, name):
         self._pyD_name = name
         self._pyD_negated = False # for aggregate with sort in descending order
-        if isinstance(name, (int, list, tuple)) or not name or name[0] not in string.ascii_uppercase + '_':
+        if isinstance(name, (int, list, tuple, xrange)) or not name or name[0] not in string.ascii_uppercase + '_':
             self._pyD_type = 'constant'
             self._pyD_lua = pyEngine.Const(name)
         else:
         if isinstance(other, type(lambda: None)):
             other = Lambda(other)
         name = '=' + str(self) + operator + str(other)
-        if other is None or isinstance(other, (int, six.string_types, list, tuple)):
+        if other is None or isinstance(other, (int, six.string_types, list, tuple, xrange)):
             literal = Literal(name, [self])
             expr = pyEngine.make_operand('constant', other)
         else: 
         self.operator = operator
         
         def _convert(operand):
-            if operand is None or isinstance(operand, (six.string_types, int, list, tuple)):
+            if operand is None or isinstance(operand, (six.string_types, int, list, tuple, xrange)):
                 return Symbol(operand)
             elif isinstance(operand, type(lambda: None)):
                 return Lambda(operand)

pyDatalog/test_of_performance.py

 results for 10 tests on Intel Core i7-2820 QM CPU @ 2.3 GHz (run from Command prompt):
 * python 2.7 : 112 sec in total
 * python 3.2 : 99 sec
-* pypy 1.9 : 23 sec
+* pypy 1.9 : 17 sec
 Note : it is significantly slower when run in debug mode (instead of from the command prompt)
 
 """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.