Skip to content

Commit

Permalink
structured dill as a package;
Browse files Browse the repository at this point in the history
updated ppathos branch with trunk updates


git-svn-id: svn+ssh://svn.mystic.cacr.caltech.edu/pathos/dill@383 8bfda07e-5b16-0410-ab1d-fd04ec2748df
  • Loading branch information
mmckerns committed Jun 19, 2010
1 parent 8ada683 commit 4ab148c
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 5 deletions.
100 changes: 100 additions & 0 deletions DEV_NOTES
Original file line number Diff line number Diff line change
@@ -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
<weakref at 0xb12f60; to 'instance' at 0xb23080>
>>> 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
<weakref at 0xb306f0; dead>
>>> r2()
>>> r2.__call__()
>>> r2.__hash__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: weak object has gone away


>>> o3 = Object()
>>> r3 = weakref.proxy(o3) #XXX: type: weakref.ProxyType

>>> r3
<weakproxy at 0x85b10 to instance at 0x8d530>
>>> o3
<__main__.Object instance at 0x8d530>
>>> r3.__class__
<class __main__.Object at 0x6aa50>
>>> o3.__class__
<class __main__.Object at 0x6aa50>

>>> del o3
>>> r3
<weakproxy at 0x85b10 to NoneType at 0x4f1aa0>
>>> r3.__class__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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
<weakproxy at 0x82930 to instance at 0x8ca30>
>>> rr()
>>> rr.__call__
<bound method Object.__call__ of <__main__.Object instance at 0x8ca30>>
>>> 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.

########################################
15 changes: 15 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -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/

6 changes: 3 additions & 3 deletions __init__.py → dill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 >
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dill.py → dill/dill.py
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
'Topic :: Physics Programming'),
packages = ['dill'],
package_dir = {'dill':''},
package_dir = {'dill':'dill'},
"""

# add dependencies
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4ab148c

Please sign in to comment.