diff -r 39ddcc5c7fb9 Modules/_pickle.c --- a/Modules/_pickle.c Sat Feb 25 19:26:39 2012 +0200 +++ b/Modules/_pickle.c Sat Feb 25 21:51:58 2012 +0100 @@ -1,3 +1,61 @@ +/* _pickle.c - C implementation of pickle.py + +This module implements the following functions: + - dump, dumps, load, loads + +This module implements the following classes: +Exceptions: + - PickleError + - PicklingError(PickleError) + - UnpicklingError(PickleError) + +Pickle protocol: + - PicklerObject (_pickle.Pickler) + - UnpicklerObject (_pickle.Unpickler) + +Memoization: + - PicklerMemoProxyObject (_pickle.PicklerMemoProxy, not directly exposed) + - UnpicklerMemoProxyObject (_pickle.UnpicklerMemoProxy, not directly exposed) + +Stack: + - Pdata (_pickle.Pdata, not directly exposed) + +The following internal structs are used: + - PyMemoTable and PyMemoItem, implementing a fast analog to the dict used + for Pickler.memo. + +The overall structure is as follows, with approximate line numbers (rounded to +nearest 50, as of february 2012): + 50 - Protocol definition + 150 - Forward declarations + 200 - Pdata implementation + 450 - PyMemoTable implementation + 700 - PicklerObject 'fast api' implementation + 900 - UnpicklerObject 'fast api' implementation +1250 - PyMemoTable implementation (continued) +1350 - PicklerObject implementation +3550 - PicklerMemoProxyObject implementation +3700 - PicklerObject implementation (continued) +3850 - UnpicklerObject implementation +5700 - UnpicklerMemoProxyObject implementation +5850 - UnpicklerObject implementation (continued) +6050 - _pickle module implementation +6500 EOF + +Both the PicklerObject and [UnpicklerObject] implementation follow the same +structure: + - a 'fast api' (functions starting with _Pickler [_Unpickler]) + - a number of saving [loading] functions save_* [load_*], corresponding to + object types [pickle opcodes], with helper functions declared just before + the functions where they are needed (e.g. raw_unicode_escape) + - a dispatcher for these functions (save [load]) + - the PicklerMemoProxyObject [UnpicklerMemoProxyObject] implementation + - functions for working with the PicklerMemoProxyObject [UnpicklerMemoPro...] + - functions for saving [loading] persistent IDs + - the object type/members/etc declaration + +*/ + #include "Python.h" #include "structmember.h"