Given a pickle dump in python how to I determine the used protocol?

Posted by SmCaterpillar on Stack Overflow See other posts from Stack Overflow or by SmCaterpillar
Published on 2013-11-06T09:05:20Z Indexed on 2013/11/07 9:54 UTC
Read the original article Hit count: 167

Filed under:
|
|

Assume that I have a pickle dump - either as a file or just as a string - how can I determine the protocol that was used to create the pickle dump automatically?

And if so, do I need to read the entire dump to figure out the protocol or can this be achieved in O(1)? By O(1) I think about some header information at the beginning of the pickle string or file whose read out does not require processing the whole dump.

Thanks a lot!

© Stack Overflow or respective owner

Related posts about python

Related posts about pickle