This is an automated email from the ASF dual-hosted git repository. spmallette pushed a commit to branch TINKERPOP-2279 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit b51e5336801e03ce5d1f9aec9de79725694aff13 Author: Stephen Mallette <[email protected]> AuthorDate: Mon Aug 26 14:19:28 2019 -0400 Create less bytearray() instances - gave a decent performance bump closed the gap on graphson by about 50% --- .../jython/gremlin_python/structure/io/graphbinaryV1.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py index c287fe0..cc2b589 100644 --- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py +++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py @@ -193,18 +193,22 @@ class _GraphBinaryTypeIO(object): "filter_": "filter", "id_": "id", "max_": "max", "min_": "min", "sum_": "sum"} @classmethod - def as_bytes(cls, graphbin_type, as_value=False, nullable=True, bytes_to_write=bytes()): - ba = bytearray() if as_value else bytearray([graphbin_type.value]) + def as_bytes(cls, graphbin_type, as_value=False, nullable=True, bytes_to_write=None, to_extend=None): + if to_extend is None: + to_extend = bytearray() + + if not as_value: + to_extend.extend([graphbin_type.value]) if nullable: - ba.extend(struct.pack(">b", 0)) + to_extend.extend(struct.pack(">b", 0)) if isinstance(bytes_to_write, (bytes, bytearray)): - ba.extend(bytes_to_write) + to_extend.extend(bytes_to_write) else: raise Exception("MISSING") - return ba + return to_extend @classmethod def read_int(cls, buff):
