mirror of
https://github.com/twitter/the-algorithm.git
synced 2025-06-12 23:58:17 -05:00
Twitter Recommendation Algorithm
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
This commit is contained in:
16
twml/twml_common/serialize.py
Normal file
16
twml/twml_common/serialize.py
Normal file
@ -0,0 +1,16 @@
|
||||
from thrift.protocol import TBinaryProtocol
|
||||
from thrift.transport import TTransport
|
||||
|
||||
|
||||
def serialize(obj):
|
||||
tbuf = TTransport.TMemoryBuffer()
|
||||
iproto = TBinaryProtocol.TBinaryProtocol(tbuf)
|
||||
obj.write(iproto)
|
||||
return tbuf.getvalue()
|
||||
|
||||
|
||||
def deserialize(record, bytes):
|
||||
tbuf = TTransport.TMemoryBuffer(bytes)
|
||||
iproto = TBinaryProtocol.TBinaryProtocol(tbuf)
|
||||
record.read(iproto)
|
||||
return record
|
Reference in New Issue
Block a user