summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2023-01-09 06:13:29 -0800
committerEli Bendersky <eliben@gmail.com>2023-01-09 06:13:29 -0800
commit489d208f09e188025f9b231a9cf2d90c05c92fbe (patch)
tree8df550ce949ed07717334eeb46abc2d6b26dc190
parent4e16079578377c215c7c387eaa2948252e54b108 (diff)
downloadpycparser-489d208f09e188025f9b231a9cf2d90c05c92fbe.tar.gz
Clean up serialize_ast example to use HIGHEST_PROTOCOL for pickling
-rw-r--r--examples/serialize_ast.py7
1 files changed, 1 insertions, 6 deletions
diff --git a/examples/serialize_ast.py b/examples/serialize_ast.py
index 8669a0a..cc6d60a 100644
--- a/examples/serialize_ast.py
+++ b/examples/serialize_ast.py
@@ -25,13 +25,8 @@ if __name__ == '__main__':
parser = c_parser.CParser()
ast = parser.parse(text)
- # Since AST nodes use __slots__ for faster attribute access and
- # space saving, it needs Pickle's protocol version >= 2.
- # The default version is 3 for python 3.x and 1 for python 2.7.
- # You can always select the highest available protocol with the -1 argument.
-
with open('ast', 'wb') as f:
- pickle.dump(ast, f, protocol=-1)
+ pickle.dump(ast, f, protocol=pickle.HIGHEST_PROTOCOL)
# Deserialize.
with open('ast', 'rb') as f: