-
Notifications
You must be signed in to change notification settings - Fork 423
Closed as not planned
Labels
Description
Overview
Be able to serialize/de-serialize Pyav objects with pickle.
Pickle raise an error, complaining about __reduce__ magic function to be implemented.
pickle.dumps(packet)
File "stringsource", line 2, in av.packet.Packet.__reduce_cython__
TypeError: no default __reduce__ due to non-trivial __cinit__Desired Behavior
Pyav objects should be able to be serialized/de-serialized with pickle.
Example API
# pickle an av.packet.Packet instance
pickled = pickle.dumps(mypacket)
# get back packet instance
unpickled = pickle.loads(pickled)To achieve that, it seems that there is a decorator in Cython since 0.26.
@cython.auto_pickle(True)
http://blog.behnel.de/posts/whats-new-in-cython-026.html
https://stackoverflow.com/questions/12646436/pickle-cython-class
Additional context
I am trying to use Pyav on Apache Spark, to distribute encoding across servers.
Pyspark (Python implementation of Spark) use pickle to transfer code object instances to servers.
So, making Pyav classes pickabled will allow to distribute Pyav jobs on a farm of servers, with pyspark or other similar tools.
mfoglio