Created
October 28, 2017 16:35
-
-
Save hvardhanx/eea651c394b48e626176906d1c2c76f6 to your computer and use it in GitHub Desktop.
Serializers + Deserializers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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