You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/08/22 22:36:21 UTC

tinkerpop git commit: cleaned up the GremlinPython source generators. Was doing some double iterations for no reason. Made the Bytecode.__repr__ better (nested list based). Updated the tutorial on gremlin-variants with new GremlinPython source generator

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 f44bad526 -> 36db3ef9e


cleaned up the GremlinPython source generators. Was doing some double iterations for no reason. Made the Bytecode.__repr__ better (nested list based). Updated the tutorial on gremlin-variants with new GremlinPython source generator code (easier to understand now).


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/36db3ef9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/36db3ef9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/36db3ef9

Branch: refs/heads/TINKERPOP-1278
Commit: 36db3ef9e140f97f3b378a95259598cf030ad748
Parents: f44bad5
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon Aug 22 16:36:17 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon Aug 22 16:36:17 2016 -0600

----------------------------------------------------------------------
 .../gremlin-language-variants/index.asciidoc    | 129 +++++++++----------
 .../python/GraphTraversalSourceGenerator.groovy | 127 +++++++++---------
 .../python/TraversalSourceGenerator.groovy      |  78 +++++------
 .../gremlin_python/process/graph_traversal.py   |  51 ++++----
 .../jython/gremlin_python/process/graphson.py   |  10 +-
 .../jython/gremlin_python/process/traversal.py  |  56 ++------
 6 files changed, 195 insertions(+), 256 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/36db3ef9/docs/src/tutorials/gremlin-language-variants/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/tutorials/gremlin-language-variants/index.asciidoc b/docs/src/tutorials/gremlin-language-variants/index.asciidoc
index e6ec9e2..8833733 100644
--- a/docs/src/tutorials/gremlin-language-variants/index.asciidoc
+++ b/docs/src/tutorials/gremlin-language-variants/index.asciidoc
@@ -321,6 +321,7 @@ class GraphTraversalSourceGenerator {
     public static void create(final String graphTraversalSourceFile) {
 
         final StringBuilder pythonClass = new StringBuilder()
+
         pythonClass.append("from .traversal import Traversal\n")
         pythonClass.append("from .traversal import TraversalStrategies\n")
         pythonClass.append("from .traversal import Bytecode\n")
@@ -341,44 +342,45 @@ class GraphTraversalSourceGenerator {
   def __repr__(self):
     return "graphtraversalsource[" + str(self.graph) + "]"
 """)
-        GraphTraversalSource.getMethods()
-                .findAll {
-            !it.name.equals("clone") &&
-                    !it.name.equals(TraversalSource.Symbols.withBindings) &&
-                    !it.name.equals(TraversalSource.Symbols.withRemote)
-        }
-                .collect { it.name }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .each { method ->
-            final Class<?> returnType = (GraphTraversalSource.getMethods() as Set).findAll {
-                it.name.equals(method)
-            }.collect {
-                it.returnType
-            }[0]
-            if (null != returnType) {
-                if (Traversal.isAssignableFrom(returnType)) {
-                    pythonClass.append(
-                            """  def ${method}(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
-    traversal.bytecode.add_step("${method}", *args)
-    return traversal
-""")
-                } else if (TraversalSource.isAssignableFrom(returnType)) {
+        GraphTraversalSource.getMethods(). // SOURCE STEPS
+                findAll { GraphTraversalSource.class.equals(it.returnType) }.
+                findAll {
+                    !it.name.equals("clone") &&
+                            !it.name.equals(TraversalSource.Symbols.withBindings) &&
+                            !it.name.equals(TraversalSource.Symbols.withRemote)
+                }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
                     pythonClass.append(
                             """  def ${method}(self, *args):
     source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
-    source.bytecode.add_source("${method}", *args)
+    source.bytecode.add_source("${SymbolHelper.toJava(method)}", *args)
     return source
 """)
                 }
-            }
-        }
-        pythonClass.append("""  def withRemote(self, remote_connection):
+        pythonClass.append(
+                """  def withRemote(self, remote_connection):
     source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
     source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
     return source
+  def withBindings(self, bindings):
+    return self
 """)
+        GraphTraversalSource.getMethods(). // SPAWN STEPS
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    pythonClass.append(
+                            """  def ${method}(self, *args):
+    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal.bytecode.add_step("${SymbolHelper.toJava(method)}", *args)
+    return traversal
+""")
+                }
         pythonClass.append("\n\n")
 
 ////////////////////
@@ -388,7 +390,6 @@ class GraphTraversalSourceGenerator {
                 """class GraphTraversal(Traversal):
   def __init__(self, graph, traversal_strategies, bytecode):
     Traversal.__init__(self, graph, traversal_strategies, bytecode)
-
   def __getitem__(self, index):
     if isinstance(index, int):
         return self.range(index, index + 1)
@@ -396,58 +397,54 @@ class GraphTraversalSourceGenerator {
         return self.range(index.start, index.stop)
     else:
         raise TypeError("Index must be int or slice")
-
   def __getattr__(self, key):
     return self.values(key)
 """)
-        GraphTraversal.getMethods()
-                .findAll { !it.name.equals("clone") }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .each { method ->
-            final Class<?> returnType = (GraphTraversal.getMethods() as Set).findAll {
-                it.name.equals(SymbolHelper.toJava(method))
-            }.collect { it.returnType }[0]
-            if (null != returnType && Traversal.isAssignableFrom(returnType)) {
-                pythonClass.append(
-                        """  def ${method}(self, *args):
-    self.bytecode.add_step("${method}", *args)
+        GraphTraversal.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { !it.name.equals("clone") }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    pythonClass.append(
+                            """  def ${method}(self, *args):
+    self.bytecode.add_step("${SymbolHelper.toJava(method)}", *args)
     return self
 """)
-            }
-        };
+                };
         pythonClass.append("\n\n")
 
 ////////////////////////
 // AnonymousTraversal //
 ////////////////////////
         pythonClass.append("class __(object):\n");
-        __.getMethods()
-                .findAll { Traversal.isAssignableFrom(it.returnType) }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .each { method ->
-            pythonClass.append(
-                    """  @staticmethod
+        __.class.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    pythonClass.append(
+                            """  @staticmethod
   def ${method}(*args):
     return GraphTraversal(None, None, Bytecode()).${method}(*args)
 """)
-        };
+                };
         pythonClass.append("\n\n")
-
-        __.class.getMethods()
-                .findAll { Traversal.class.isAssignableFrom(it.getReturnType()) }
-                .findAll { Modifier.isStatic(it.getModifiers()) }
-                .findAll { !it.name.equals("__") }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .forEach {
-            pythonClass.append("def ${it}(*args):\n").append("      return __.${it}(*args)\n\n")
-            pythonClass.append("statics.add_static('${it}', ${it})\n\n")
-        }
+        // add to gremlin.python.statics
+        __.class.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { !it.name.equals("__") }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach {
+                    pythonClass.append("def ${it}(*args):\n").append("      return __.${it}(*args)\n\n")
+                    pythonClass.append("statics.add_static('${it}', ${it})\n\n")
+                }
         pythonClass.append("\n\n")
 
 // save to a python file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/36db3ef9/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
index 4c307a3..8ba4ee7 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/GraphTraversalSourceGenerator.groovy
@@ -19,7 +19,6 @@
 
 package org.apache.tinkerpop.gremlin.python
 
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
@@ -76,46 +75,45 @@ under the License.
   def __repr__(self):
     return "graphtraversalsource[" + str(self.graph) + "]"
 """)
-        GraphTraversalSource.getMethods()
-                .findAll {
-            !it.name.equals("clone") &&
-                    !it.name.equals(TraversalSource.Symbols.withBindings) &&
-                    !it.name.equals(TraversalSource.Symbols.withRemote)
-        }
-                .collect { it.name }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .each { method ->
-            final Class<?> returnType = (GraphTraversalSource.getMethods() as Set).findAll {
-                it.name.equals(method)
-            }.collect {
-                it.returnType
-            }[0]
-            if (null != returnType) {
-                if (Traversal.isAssignableFrom(returnType)) {
-                    pythonClass.append(
-                            """  def ${method}(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
-    traversal.bytecode.add_step("${method}", *args)
-    return traversal
-""")
-                } else if (TraversalSource.isAssignableFrom(returnType)) {
+        GraphTraversalSource.getMethods(). // SOURCE STEPS
+                findAll { GraphTraversalSource.class.equals(it.returnType) }.
+                findAll {
+                    !it.name.equals("clone") &&
+                            !it.name.equals(TraversalSource.Symbols.withBindings) &&
+                            !it.name.equals(TraversalSource.Symbols.withRemote)
+                }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
                     pythonClass.append(
                             """  def ${method}(self, *args):
     source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
-    source.bytecode.add_source("${method}", *args)
+    source.bytecode.add_source("${SymbolHelper.toJava(method)}", *args)
     return source
 """)
                 }
-            }
-        }
-        pythonClass.append("""  def withRemote(self, remote_connection):
+        pythonClass.append(
+                """  def withRemote(self, remote_connection):
     source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
     source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
     return source
   def withBindings(self, bindings):
     return self
 """)
+        GraphTraversalSource.getMethods(). // SPAWN STEPS
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    pythonClass.append(
+                            """  def ${method}(self, *args):
+    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal.bytecode.add_step("${SymbolHelper.toJava(method)}", *args)
+    return traversal
+""")
+                }
         pythonClass.append("\n\n")
 
 ////////////////////
@@ -125,7 +123,6 @@ under the License.
                 """class GraphTraversal(Traversal):
   def __init__(self, graph, traversal_strategies, bytecode):
     Traversal.__init__(self, graph, traversal_strategies, bytecode)
-
   def __getitem__(self, index):
     if isinstance(index, int):
         return self.range(index, index + 1)
@@ -133,58 +130,54 @@ under the License.
         return self.range(index.start, index.stop)
     else:
         raise TypeError("Index must be int or slice")
-
   def __getattr__(self, key):
     return self.values(key)
 """)
-        GraphTraversal.getMethods()
-                .findAll { !it.name.equals("clone") }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .each { method ->
-            final Class<?> returnType = (GraphTraversal.getMethods() as Set).findAll {
-                it.name.equals(SymbolHelper.toJava(method))
-            }.collect { it.returnType }[0]
-            if (null != returnType && Traversal.isAssignableFrom(returnType)) {
-                pythonClass.append(
-                        """  def ${method}(self, *args):
-    self.bytecode.add_step("${method}", *args)
+        GraphTraversal.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { !it.name.equals("clone") }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    pythonClass.append(
+                            """  def ${method}(self, *args):
+    self.bytecode.add_step("${SymbolHelper.toJava(method)}", *args)
     return self
 """)
-            }
-        };
+                };
         pythonClass.append("\n\n")
 
 ////////////////////////
 // AnonymousTraversal //
 ////////////////////////
         pythonClass.append("class __(object):\n");
-        __.getMethods()
-                .findAll { Traversal.isAssignableFrom(it.returnType) }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .each { method ->
-            pythonClass.append(
-                    """  @staticmethod
+        __.class.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach { method ->
+                    pythonClass.append(
+                            """  @staticmethod
   def ${method}(*args):
     return GraphTraversal(None, None, Bytecode()).${method}(*args)
 """)
-        };
+                };
         pythonClass.append("\n\n")
-
-        __.class.getMethods()
-                .findAll { Traversal.class.isAssignableFrom(it.getReturnType()) }
-                .findAll { Modifier.isStatic(it.getModifiers()) }
-                .findAll { !it.name.equals("__") }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .forEach {
-            pythonClass.append("def ${it}(*args):\n").append("      return __.${it}(*args)\n\n")
-            pythonClass.append("statics.add_static('${it}', ${it})\n\n")
-        }
+        // add to gremlin.python.statics
+        __.class.getMethods().
+                findAll { GraphTraversal.class.equals(it.returnType) }.
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { !it.name.equals("__") }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach {
+                    pythonClass.append("def ${it}(*args):\n").append("      return __.${it}(*args)\n\n")
+                    pythonClass.append("statics.add_static('${it}', ${it})\n\n")
+                }
         pythonClass.append("\n\n")
 
 // save to a python file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/36db3ef9/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
index 69c3051..4bab256 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
@@ -66,13 +66,10 @@ class Traversal(object):
         self.side_effects = {}
         self.traversers = None
         self.last_traverser = None
-
     def __repr__(self):
         return str(self.bytecode)
-
     def __iter__(self):
         return self
-
     def __next__(self):
         if self.traversers is None:
             self.traversal_strategies.apply_strategies(self)
@@ -83,13 +80,10 @@ class Traversal(object):
         if self.last_traverser.bulk <= 0:
             self.last_traverser = None
         return object
-
     def toList(self):
         return list(iter(self))
-
     def toSet(self):
         return set(iter(self))
-
     def nextTraverser(self):
         if self.traversers is None:
             self.traversal_strategies.apply_strategies(self)
@@ -99,7 +93,6 @@ class Traversal(object):
             temp = self.last_traverser
             self.last_traverser = None
             return temp
-
     def next(self, amount=None):
         if amount is None:
             return self.__next__()
@@ -113,6 +106,7 @@ class Traversal(object):
                 tempList.append(temp)
             return tempList
 
+
 """)
 
 ///////////
@@ -126,7 +120,7 @@ class Traversal(object):
             enumClass.getEnumConstants()
                     .sort { a, b -> a.name() <=> b.name() }
                     .each { value -> pythonClass.append("${SymbolHelper.toPython(value.name())} "); }
-            pythonClass.deleteCharAt(pythonClass.length() - 1).append("')\n\n")
+            pythonClass.deleteCharAt(pythonClass.length() - 1).append("')\n")
             enumClass.getEnumConstants().each { value ->
                 pythonClass.append("statics.add_static('${SymbolHelper.toPython(value.name())}', ${value.getDeclaringClass().getSimpleName()}.${SymbolHelper.toPython(value.name())})\n");
             }
@@ -140,38 +134,38 @@ class Traversal(object):
       self.value = value
       self.other = other
 """)
-        P.class.getMethods()
-                .findAll { Modifier.isStatic(it.getModifiers()) }
-                .findAll { P.class.isAssignableFrom(it.returnType) }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .each { method ->
-            pythonClass.append(
-                    """   @staticmethod
+        P.class.getMethods().
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { P.class.isAssignableFrom(it.returnType) }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                each { method ->
+                    pythonClass.append(
+                            """   @staticmethod
    def ${method}(*args):
       return P("${SymbolHelper.toJava(method)}", *args)
 """)
-        };
+                };
         pythonClass.append("""   def _and(self, arg):
-      return P("_and", arg, self)
+      return P("and", arg, self)
    def _or(self, arg):
-      return P("_or", arg, self)
+      return P("or", arg, self)
    def __repr__(self):
       return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")"
 """)
         pythonClass.append("\n")
-        P.class.getMethods()
-                .findAll { Modifier.isStatic(it.getModifiers()) }
-                .findAll { !it.name.equals("clone") }
-                .findAll { P.class.isAssignableFrom(it.getReturnType()) }
-                .collect { SymbolHelper.toPython(it.name) }
-                .unique()
-                .sort { a, b -> a <=> b }
-                .forEach {
-            pythonClass.append("def ${it}(*args):\n").append("      return P.${it}(*args)\n\n")
-            pythonClass.append("statics.add_static('${it}',${it})\n\n")
-        }
+        P.class.getMethods().
+                findAll { Modifier.isStatic(it.getModifiers()) }.
+                findAll { !it.name.equals("clone") }.
+                findAll { P.class.isAssignableFrom(it.getReturnType()) }.
+                collect { SymbolHelper.toPython(it.name) }.
+                unique().
+                sort { a, b -> a <=> b }.
+                forEach {
+                    pythonClass.append("def ${it}(*args):\n").append("      return P.${it}(*args)\n")
+                    pythonClass.append("statics.add_static('${it}',${it})\n\n")
+                }
         pythonClass.append("\n")
         //////////////
 
@@ -193,14 +187,11 @@ TRAVERSAL STRATEGIES
 
 class TraversalStrategies(object):
     global_cache = {}
-
     def __init__(self, traversal_strategies=None):
         self.traversal_strategies = traversal_strategies.traversal_strategies if traversal_strategies is not None else []
         return
-
     def add_strategies(self, traversal_strategies):
         self.traversal_strategies = self.traversal_strategies + traversal_strategies
-
     def apply_strategies(self, traversal):
         for traversal_strategy in self.traversal_strategies:
             traversal_strategy.apply(traversal)
@@ -224,21 +215,18 @@ class Bytecode(object):
         if bytecode is not None:
             self.source_instructions = list(bytecode.source_instructions)
             self.step_instructions = list(bytecode.step_instructions)
-
     def add_source(self, source_name, *args):
-        newArgs = ()
+        instruction = [source_name]
         for arg in args:
-            newArgs = newArgs + (self.__convertArgument(arg),)
-        self.source_instructions.append((source_name, newArgs))
+            instruction.append(self.__convertArgument(arg))
+        self.source_instructions.append(instruction)
         return
-
     def add_step(self, step_name, *args):
-        newArgs = ()
+        instruction = [step_name]
         for arg in args:
-            newArgs = newArgs + (self.__convertArgument(arg),)
-        self.step_instructions.append((step_name, newArgs))
+            instruction.append(self.__convertArgument(arg))
+        self.step_instructions.append(instruction)
         return
-
     def __convertArgument(self,arg):
         if isinstance(arg, Traversal):
             self.bindings.update(arg.bytecode.bindings)
@@ -248,9 +236,9 @@ class Bytecode(object):
             return Binding(arg[0],arg[1])
         else:
             return arg
-
     def __repr__(self):
-        return str(self.source_instructions) + str(self.step_instructions)
+        return (str(self.source_instructions) if len(self.source_instructions) > 0 else "") + \\
+               (str(self.step_instructions) if len(self.step_instructions) > 0 else "")
 
 
 '''

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/36db3ef9/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
index 2ebdef1..c7a63b7 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graph_traversal.py
@@ -31,22 +31,6 @@ class GraphTraversalSource(object):
     self.bytecode = bytecode
   def __repr__(self):
     return "graphtraversalsource[" + str(self.graph) + "]"
-  def E(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
-    traversal.bytecode.add_step("E", *args)
-    return traversal
-  def V(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
-    traversal.bytecode.add_step("V", *args)
-    return traversal
-  def addV(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
-    traversal.bytecode.add_step("addV", *args)
-    return traversal
-  def inject(self, *args):
-    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
-    traversal.bytecode.add_step("inject", *args)
-    return traversal
   def withBulk(self, *args):
     source = GraphTraversalSource(self.graph, TraversalStrategies(self.traversal_strategies), Bytecode(self.bytecode))
     source.bytecode.add_source("withBulk", *args)
@@ -81,12 +65,27 @@ class GraphTraversalSource(object):
     return source
   def withBindings(self, bindings):
     return self
+  def E(self, *args):
+    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal.bytecode.add_step("E", *args)
+    return traversal
+  def V(self, *args):
+    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal.bytecode.add_step("V", *args)
+    return traversal
+  def addV(self, *args):
+    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal.bytecode.add_step("addV", *args)
+    return traversal
+  def inject(self, *args):
+    traversal = GraphTraversal(self.graph, self.traversal_strategies, Bytecode(self.bytecode))
+    traversal.bytecode.add_step("inject", *args)
+    return traversal
 
 
 class GraphTraversal(Traversal):
   def __init__(self, graph, traversal_strategies, bytecode):
     Traversal.__init__(self, graph, traversal_strategies, bytecode)
-
   def __getitem__(self, index):
     if isinstance(index, int):
         return self.range(index, index + 1)
@@ -94,32 +93,31 @@ class GraphTraversal(Traversal):
         return self.range(index.start, index.stop)
     else:
         raise TypeError("Index must be int or slice")
-
   def __getattr__(self, key):
     return self.values(key)
   def V(self, *args):
     self.bytecode.add_step("V", *args)
     return self
   def _and(self, *args):
-    self.bytecode.add_step("_and", *args)
+    self.bytecode.add_step("and", *args)
     return self
   def _as(self, *args):
-    self.bytecode.add_step("_as", *args)
+    self.bytecode.add_step("as", *args)
     return self
   def _from(self, *args):
-    self.bytecode.add_step("_from", *args)
+    self.bytecode.add_step("from", *args)
     return self
   def _in(self, *args):
-    self.bytecode.add_step("_in", *args)
+    self.bytecode.add_step("in", *args)
     return self
   def _is(self, *args):
-    self.bytecode.add_step("_is", *args)
+    self.bytecode.add_step("is", *args)
     return self
   def _not(self, *args):
-    self.bytecode.add_step("_not", *args)
+    self.bytecode.add_step("not", *args)
     return self
   def _or(self, *args):
-    self.bytecode.add_step("_or", *args)
+    self.bytecode.add_step("or", *args)
     return self
   def addE(self, *args):
     self.bytecode.add_step("addE", *args)
@@ -136,9 +134,6 @@ class GraphTraversal(Traversal):
   def aggregate(self, *args):
     self.bytecode.add_step("aggregate", *args)
     return self
-  def asAdmin(self, *args):
-    self.bytecode.add_step("asAdmin", *args)
-    return self
   def barrier(self, *args):
     self.bytecode.add_step("barrier", *args)
     return self

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/36db3ef9/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/graphson.py b/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
index 1474f26..fcc381a 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/graphson.py
@@ -60,15 +60,15 @@ class BytecodeSerializer(GraphSONSerializer):
         sources = []
         for instruction in bytecode.source_instructions:
             inst = []
-            inst.append(_SymbolHelper.toGremlin(instruction[0]))
-            for arg in instruction[1]:
+            inst.append(instruction[0])
+            for arg in instruction[1:]:
                 inst.append(GraphSONWriter._dictify(arg))
             sources.append(inst)
         steps = []
         for instruction in bytecode.step_instructions:
             inst = []
-            inst.append(_SymbolHelper.toGremlin(instruction[0]))
-            for arg in instruction[1]:
+            inst.append(instruction[0])
+            for arg in instruction[1:]:
                 inst.append(GraphSONWriter._dictify(arg))
             steps.append(inst)
         if len(sources) > 0:
@@ -90,7 +90,7 @@ class PSerializer(GraphSONSerializer):
     def _dictify(self, p):
         dict = {}
         dict["@type"] = "P"
-        dict["predicate"] = _SymbolHelper.toGremlin(p.operator)
+        dict["predicate"] = p.operator
         if p.other is None:
             dict["value"] = GraphSONWriter._dictify(p.value)
         else:

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/36db3ef9/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index 60f5649..4aa8e4d 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -28,13 +28,10 @@ class Traversal(object):
         self.side_effects = {}
         self.traversers = None
         self.last_traverser = None
-
     def __repr__(self):
         return str(self.bytecode)
-
     def __iter__(self):
         return self
-
     def __next__(self):
         if self.traversers is None:
             self.traversal_strategies.apply_strategies(self)
@@ -45,13 +42,10 @@ class Traversal(object):
         if self.last_traverser.bulk <= 0:
             self.last_traverser = None
         return object
-
     def toList(self):
         return list(iter(self))
-
     def toSet(self):
         return set(iter(self))
-
     def nextTraverser(self):
         if self.traversers is None:
             self.traversal_strategies.apply_strategies(self)
@@ -61,7 +55,6 @@ class Traversal(object):
             temp = self.last_traverser
             self.last_traverser = None
             return temp
-
     def next(self, amount=None):
         if amount is None:
             return self.__next__()
@@ -75,29 +68,25 @@ class Traversal(object):
                 tempList.append(temp)
             return tempList
 
-Barrier = Enum('Barrier', 'normSack')
 
+Barrier = Enum('Barrier', 'normSack')
 statics.add_static('normSack', Barrier.normSack)
 
 Cardinality = Enum('Cardinality', 'list set single')
-
 statics.add_static('single', Cardinality.single)
 statics.add_static('list', Cardinality.list)
 statics.add_static('set', Cardinality.set)
 
 Column = Enum('Column', 'keys values')
-
 statics.add_static('keys', Column.keys)
 statics.add_static('values', Column.values)
 
 Direction = Enum('Direction', 'BOTH IN OUT')
-
 statics.add_static('OUT', Direction.OUT)
 statics.add_static('IN', Direction.IN)
 statics.add_static('BOTH', Direction.BOTH)
 
 Operator = Enum('Operator', 'addAll _and assign div max min minus mult _or sum sumLong')
-
 statics.add_static('sum', Operator.sum)
 statics.add_static('minus', Operator.minus)
 statics.add_static('mult', Operator.mult)
@@ -111,7 +100,6 @@ statics.add_static('addAll', Operator.addAll)
 statics.add_static('sumLong', Operator.sumLong)
 
 Order = Enum('Order', 'decr incr keyDecr keyIncr shuffle valueDecr valueIncr')
-
 statics.add_static('incr', Order.incr)
 statics.add_static('decr', Order.decr)
 statics.add_static('keyIncr', Order.keyIncr)
@@ -121,18 +109,15 @@ statics.add_static('valueDecr', Order.valueDecr)
 statics.add_static('shuffle', Order.shuffle)
 
 Pop = Enum('Pop', 'all first last')
-
 statics.add_static('first', Pop.first)
 statics.add_static('last', Pop.last)
 statics.add_static('all', Pop.all)
 
 Scope = Enum('Scope', '_global local')
-
 statics.add_static('_global', Scope._global)
 statics.add_static('local', Scope.local)
 
 T = Enum('T', 'id key label value')
-
 statics.add_static('label', T.label)
 statics.add_static('id', T.id)
 statics.add_static('key', T.key)
@@ -183,75 +168,62 @@ class P(object):
    def without(*args):
       return P("without", *args)
    def _and(self, arg):
-      return P("_and", arg, self)
+      return P("and", arg, self)
    def _or(self, arg):
-      return P("_or", arg, self)
+      return P("or", arg, self)
    def __repr__(self):
       return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")"
 
 def _not(*args):
       return P._not(*args)
-
 statics.add_static('_not',_not)
 
 def between(*args):
       return P.between(*args)
-
 statics.add_static('between',between)
 
 def eq(*args):
       return P.eq(*args)
-
 statics.add_static('eq',eq)
 
 def gt(*args):
       return P.gt(*args)
-
 statics.add_static('gt',gt)
 
 def gte(*args):
       return P.gte(*args)
-
 statics.add_static('gte',gte)
 
 def inside(*args):
       return P.inside(*args)
-
 statics.add_static('inside',inside)
 
 def lt(*args):
       return P.lt(*args)
-
 statics.add_static('lt',lt)
 
 def lte(*args):
       return P.lte(*args)
-
 statics.add_static('lte',lte)
 
 def neq(*args):
       return P.neq(*args)
-
 statics.add_static('neq',neq)
 
 def outside(*args):
       return P.outside(*args)
-
 statics.add_static('outside',outside)
 
 def test(*args):
       return P.test(*args)
-
 statics.add_static('test',test)
 
 def within(*args):
       return P.within(*args)
-
 statics.add_static('within',within)
 
 def without(*args):
       return P.without(*args)
-
 statics.add_static('without',without)
 
 
@@ -273,14 +245,11 @@ TRAVERSAL STRATEGIES
 
 class TraversalStrategies(object):
     global_cache = {}
-
     def __init__(self, traversal_strategies=None):
         self.traversal_strategies = traversal_strategies.traversal_strategies if traversal_strategies is not None else []
         return
-
     def add_strategies(self, traversal_strategies):
         self.traversal_strategies = self.traversal_strategies + traversal_strategies
-
     def apply_strategies(self, traversal):
         for traversal_strategy in self.traversal_strategies:
             traversal_strategy.apply(traversal)
@@ -304,21 +273,18 @@ class Bytecode(object):
         if bytecode is not None:
             self.source_instructions = list(bytecode.source_instructions)
             self.step_instructions = list(bytecode.step_instructions)
-
     def add_source(self, source_name, *args):
-        newArgs = ()
+        instruction = [source_name]
         for arg in args:
-            newArgs = newArgs + (self.__convertArgument(arg),)
-        self.source_instructions.append((source_name, newArgs))
+            instruction.append(self.__convertArgument(arg))
+        self.source_instructions.append(instruction)
         return
-
     def add_step(self, step_name, *args):
-        newArgs = ()
+        instruction = [step_name]
         for arg in args:
-            newArgs = newArgs + (self.__convertArgument(arg),)
-        self.step_instructions.append((step_name, newArgs))
+            instruction.append(self.__convertArgument(arg))
+        self.step_instructions.append(instruction)
         return
-
     def __convertArgument(self,arg):
         if isinstance(arg, Traversal):
             self.bindings.update(arg.bytecode.bindings)
@@ -328,9 +294,9 @@ class Bytecode(object):
             return Binding(arg[0],arg[1])
         else:
             return arg
-
     def __repr__(self):
-        return str(self.source_instructions) + str(self.step_instructions)
+        return (str(self.source_instructions) if len(self.source_instructions) > 0 else "") + \
+               (str(self.step_instructions) if len(self.step_instructions) > 0 else "")
 
 
 '''