Bugs item #998998, was opened at 2004-07-27 22:55 Message generated for change (Comment added) made by grubert You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=998998&group_id=5470
Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Skip Montanaro (montanaro) Assigned to: Nobody/Anonymous (nobody) Summary: pickle bug - recursively memoizing class? Initial Comment: The attached script (picklecycle.py) gives me an assertion error in Pickler.memoize(). Maybe I'm just doing something dumb. I have very little experience with pickle and even less experience pickling new-style class instances. I'm just trying to adapt an existing messy object graph to allow it to be pickled. I realize the two instances refer to each other, but I thought pickle was supposed to gracefully handle cyclic object graphs. I can worm around the problem a couple ways. First, getting rid of new-style classes does the trick. Also modifying B.__reduce__ to not return self.__dict__ seems to do the trick. Output (cycle.out) and a modified version of Pickler.memoize (memoize.py) will be attached momentarily. ---------------------------------------------------------------------- Comment By: engelbert gruber (grubert) Date: 2005-05-19 13:00 Message: Logged In: YES user_id=147070 it does memoize recursively, but "asserts" not to get stuck in cycles. that's how i understand the code if :: assert id(obj) not in self.memo is replaced by :: if id(obj) in self.memo: return it works (better). and test_pickle.py still passes. ---------------------------------------------------------------------- Comment By: Skip Montanaro (montanaro) Date: 2004-07-27 22:57 Message: Logged In: YES user_id=44345 Attaching the output I see when running picklecycle.py w/ the modified memoize() method (cycle.out). ---------------------------------------------------------------------- Comment By: Skip Montanaro (montanaro) Date: 2004-07-27 22:56 Message: Logged In: YES user_id=44345 Attaching chatty version of Pickler.memoize() ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=998998&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com