[SciPy-User] Pickling timeseries Dates

David Baddeley david_baddeley@yahoo.com...
Thu Dec 10 22:28:17 CST 2009


It also shouldn't be to hard to register a new pickle handler that takes care of the conversion to e.g. datetime for you. I'm not familiar with timeseries stuff, but wrote something similar to let me pickle slices, which I've included below - as you can see it's pretty trivial. After that you can carry on treating your date (slice) objects as though they were picklable.

import copy_reg

def pickleSlice(slice):
        return unpickleSlice, (slice.start, slice.stop, slice.step)

def unpickleSlice(start, stop, step):
        return slice(start, stop, step)

copy_reg.pickle(slice, pickleSlice, unpickleSlice)

best wishes,
David



--- On Fri, 11/12/09, Pierre GM <pgmdevlist@gmail.com> wrote:

> From: Pierre GM <pgmdevlist@gmail.com>
> Subject: Re: [SciPy-User] Pickling timeseries Dates
> To: "SciPy Users List" <scipy-user@scipy.org>
> Received: Friday, 11 December, 2009, 4:37 PM
> On Dec 10, 2009, at 10:12 PM, Robert
> Ferrell wrote:
> >> 
> > Fernando reminded me that any date scalar will trigger
> the pickle  
> > problem.  Some of my objects have Date instances
> stashed all over the  
> > place.  Converting all those to single-element
> DateArrays is not  
> > feasible.
> 
> And converting them to something else, like a datetime or
> even just a tuple (value,freq)
> 
> 
> > 
> > Why can't Date instances be pickled, and how hard
> would it be to  
> > change that?
> 
> 
> because we never implemented it on the C side, and that'll
> depend on whether Matt Knox can do it or not.
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
> 


      


More information about the SciPy-User mailing list