From 489d208f09e188025f9b231a9cf2d90c05c92fbe Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Mon, 9 Jan 2023 06:13:29 -0800 Subject: [PATCH] Clean up serialize_ast example to use HIGHEST_PROTOCOL for pickling --- examples/serialize_ast.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/examples/serialize_ast.py b/examples/serialize_ast.py index 8669a0a2..cc6d60a7 100644 --- a/examples/serialize_ast.py +++ b/examples/serialize_ast.py @@ -25,13 +25,8 @@ 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: