rossant / ipycache

Defines a %%cache cell magic in the IPython notebook to cache results of long-lasting computations in a persistent pickle file
BSD 3-Clause "New" or "Revised" License
138 stars 35 forks source link

adding optional use of cloudpickle module #36

Closed fbnrst closed 9 years ago

fbnrst commented 9 years ago

A PR from a clean branch based on the discussion in #35.

ihrke commented 9 years ago

Thanks, again!

ihrke commented 9 years ago

btw, just thought about something: what happens if you pickle.load() a lambda-function that has been pickled with cloudpickle? This is what always happens, the way we are currently handling it...

fbnrst commented 9 years ago

This works: https://github.com/cloudpipe/cloudpickle#examples

rossant commented 9 years ago

thanks @fabianrost84 !

fbnrst commented 9 years ago

Now, I was wondering if the except clause should only handle ImportError. Could there possibly be another exception for that we want to fall back to the standard pickle module for dumping? E.g. a broken cloudpickle module that can be imported but does not provide a dumpfunction. So should we maybe let all exceptions being handled like that:

try:
   import cloudpickle
   dump = cloudpickle.dump
except:
   dump = pickle.dump