diff --git a/DEV_NOTES b/DEV_NOTES new file mode 100644 index 00000000..de7fc5db --- /dev/null +++ b/DEV_NOTES @@ -0,0 +1,100 @@ +create a weakref: + +>>> import dill +>>> import weakref +>>> class Object: +... pass +... +>>> o = Object() +>>> r = weakref.ref(o) #XXX: type: weakref.ReferenceType + +>>> r + +>>> o +<__main__.Object instance at 0xb23080> +>>> r() +<__main__.Object instance at 0xb23080> +>>> r.__call__() +<__main__.Object instance at 0xb23080> +>>> r.__hash__() +11677824 +>>> id(o) +11677824 + + +>>> o2 = Object() +>>> r2 = weakref.ref(o2) +>>> del o2 + +>>> r2 + +>>> r2() +>>> r2.__call__() +>>> r2.__hash__() +Traceback (most recent call last): + File "", line 1, in +TypeError: weak object has gone away + + +>>> o3 = Object() +>>> r3 = weakref.proxy(o3) #XXX: type: weakref.ProxyType + +>>> r3 + +>>> o3 +<__main__.Object instance at 0x8d530> +>>> r3.__class__ + +>>> o3.__class__ + + +>>> del o3 +>>> r3 + +>>> r3.__class__ +Traceback (most recent call last): + File "", line 1, in +ReferenceError: weakly-referenced object no longer exists + + +>>> class Object2: +... def __call__(self): +... pass +... +>>> oo = Object2() +>>> oo +<__main__.Object instance at 0x8ca30> +>>> oo() +>>> rr = weakref.proxy(oo) #XXX: type: weakref.CallableProxyType +>>> rr + +>>> rr() +>>> rr.__call__ +> +>>> rr.__call__() +>>> + + + +######################################## +approach to pickling weakrefs: + +*) register the weakref types ? (see line ~228 of dill.py) + +*) use hash to create hard copy of ref object + then upon unpickle, create new weakref + +*) propose that pickling a weakref will always provide a dead reference + unless the reference object is pickled along with the weakref + +######################################## +pickling generators: + +*) need to avoid the "new" method for FrameTypes... +don't see how to do that, without going into C to get the GID Thread. + +*) currently inspecting: Objects/object.c Objects/dictobject.c Objects/genobject.c Objects/frameobject.c Python/pystate.c Python/thread.c Python/pythonrun.c + +*) the package "generator_tools" may have the answer. + +######################################## diff --git a/README b/README new file mode 100644 index 00000000..8a36f083 --- /dev/null +++ b/README @@ -0,0 +1,15 @@ +dill: a utility for serialization of python objects + +Current release: + dill-0.1a1 + +Installation: + $ python setup.py build + $ python setup.py install + +License: + >>> print dill.__license__ + +More information: + http://www.cacr.caltech.edu/~mmckerns/ + diff --git a/__init__.py b/dill/__init__.py similarity index 95% rename from __init__.py rename to dill/__init__.py index 53622dfc..40898bfb 100644 --- a/__init__.py +++ b/dill/__init__.py @@ -3,12 +3,12 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Mike McKerns, Caltech -# (C) 2008-2009 All Rights Reserved +# (C) 2008-2010 All Rights Reserved # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # """ -dill: a full python state pickler +dill: a utility for serialization of python objects < package summary > @@ -112,7 +112,7 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Copyright (c) 2009 California Institute of Technology. All rights reserved. +Copyright (c) 2010 California Institute of Technology. All rights reserved. If you use this software to do productive scientific research that leads to diff --git a/dill.py b/dill/dill.py similarity index 99% rename from dill.py rename to dill/dill.py index b9df6615..8a361a0f 100644 --- a/dill.py +++ b/dill/dill.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -dill: a full python state pickler +dill: a utility for serialization of python objects Based on code written by Oren Tirosh and Armin Ronacher. Extended to a (near) full set of python types (in types module), diff --git a/setup.py b/setup.py index 4c5c2fe9..fdd17d7a 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ 'Topic :: Physics Programming'), packages = ['dill'], - package_dir = {'dill':''}, + package_dir = {'dill':'dill'}, """ # add dependencies diff --git a/dill_bugs.py b/tests/dill_bugs.py similarity index 100% rename from dill_bugs.py rename to tests/dill_bugs.py diff --git a/dill_test.py b/tests/dill_test.py similarity index 100% rename from dill_test.py rename to tests/dill_test.py diff --git a/dill_test2.py b/tests/dill_test2.py similarity index 100% rename from dill_test2.py rename to tests/dill_test2.py