Skip to content

Instantly share code, notes, and snippets.

@hvardhanx
Created October 28, 2017 16:35
Show Gist options
  • Save hvardhanx/eea651c394b48e626176906d1c2c76f6 to your computer and use it in GitHub Desktop.
Save hvardhanx/eea651c394b48e626176906d1c2c76f6 to your computer and use it in GitHub Desktop.
Serializers + Deserializers
from . import encode
from . import packer
+import pickle
from . import compat
from .compat import range_func
@@ -391,6 +392,14 @@ class Builder(object):
self.PlaceUOffsetT(vectorNumElems)
return self.Offset()
+ def SerializeToString(self, s):
+ serialized = pickle.dumps(s)
+ return serialized
+
+ def FromString(self, s):
+ deserialized = pickle.loads(s)
+ return deserialized
+
def CreateString(self, s, encoding='utf-8', errors='strict'):
"""CreateString writes a null-terminated byte string as a vector."""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment