Created
August 3, 2013 07:12
-
-
Save wzpan/6145555 to your computer and use it in GitHub Desktop.
Python - pickle version
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
| # usage: | |
| # >>> import pickleversion | |
| # >>> with open('entry.pickle', 'rb') as f: | |
| # ... v = pickleversion.protocol_version(f) | |
| # >>> v | |
| import pickletools | |
| def protocol_version(file_object): | |
| maxproto = -1 | |
| for opcode, arg, pos in pickletools.genops(file_object): | |
| maxproto = max(maxproto, opcode.proto) | |
| return maxproto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment