On Tue, Nov 23, 2010 at 11:16 PM, cool-RR <[email protected]> wrote:
> On Tue, Nov 23, 2010 at 11:01 PM, Shai Berger <[email protected]> wrote: > >> Hi Ram and all, >> >> 1) To me, it makes more sense to define the property you seek on the >> negative: >> an object is "atomically unpicklable", or "inherently unpicklable", if it >> cannot be pickled, for any value of its attributes. >> > > Yeah, I guess that makes more sense; However, I'd still like to present a > positive function to the user (`is_atomically_pickleable`) and not a > negative one. (`is_inherently_unpickleable`). But I wouldn't complain if I > was given the latter :) > > > >> 2) I'm not sure how you'd characterize a good answer; I think Laurence >> Gonsalves' answer on StackOverflow is quite good. >> > > Laurence's answer seems wrong to me. He's calling the pickler, and on > consequence is that the pickler does the `__reduce__` dance, but that seems > like overkill. I think this causes waste. (Probably doing the actual > pickling of the object instead of just checking if it's possible.) Checking > if an object is atomically pickleable should not involve the object at all; > Only its type. > > > Ram. > Hello all, I released the `pickle_tools` module which does exactly what I asked for: https://github.com/cool-RR/GarlicSim/blob/master/garlicsim/garlicsim/general_misc/pickle_tools.py Here are its tests<https://github.com/cool-RR/GarlicSim/tree/master/garlicsim/test_garlicsim/test_general_misc/test_pickle_tools> . You can use it by installing `garlicsim` and doing `from garlicsim.general_misc import pickle_tools`. The function I was talking about in this thread is `is_atomically_pickleable`. Everything is explained in the docstrings. There is even a Python 3 version on the Python 3 fork of GarlicSim<http://pypi.python.org/pypi/garlicsim_py3>. So you can use it on Python 3 code. Enjoy, Ram.
_______________________________________________ Python-il mailing list [email protected] http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il
