dill scripts documentation

get_objgraph script

display the reference paths for objects in dill.types or a .pkl file

Notes

the generated image is useful in showing the pointer references in objects that are or can be pickled. Any object in dill.objects listed in dill.load_types(picklable=True, unpicklable=True) works.

Examples:

$ get_objgraph ArrayType
Image generated as ArrayType.png
load_types(pickleable=True, unpickleable=True)

load pickleable and/or unpickleable types to dill.types

dill.types is meant to mimic the types module, providing a registry of object types. By default, the module is empty (for import speed purposes). Use the load_types function to load selected object types to the dill.types module.

Parameters:
  • pickleable (bool, default=True) – if True, load pickleable types.

  • unpickleable (bool, default=True) – if True, load unpickleable types.

Returns:

None

get_gprof script

build profile graph for the given instance

running:

$ get_gprof <args> <instance>

executes:

gprof2dot -f pstats <args> <type>.prof | dot -Tpng -o <type>.call.png

where:

<args> are arguments for gprof2dot, such as “-n 5 -e 5” <instance> is code to create the instance to profile <type> is the class of the instance (i.e. type(instance))

For example:

$ get_gprof -n 5 -e 1 “import numpy; numpy.array([1,2])”

will create ‘ndarray.call.png’ with the profile graph for numpy.array([1,2]), where ‘-n 5’ eliminates nodes below 5% threshold, similarly ‘-e 1’ eliminates edges below 1% threshold

undill script

unpickle the contents of a pickled object file

Examples:

$ undill hello.pkl
['hello', 'world']