On Wed, Apr 11, 2012 at 4:32 AM, Barry Warsaw <[email protected]> wrote:
> On Apr 10, 2012, at 12:00 PM, Ryan Haynes wrote:
>
>>I recently started using storm. Thanks a lot for the work on this. A
>>quick question... I have relatively sparse numpy objects that I'd like
>>to persist into RawStr. Would it make sense to add a compression
>>facility into the Columns that accept blobs? I currently just do the
>>following...
>
> Do you know about Pickle() types?
>
> class MailingList(Model):
> implements(IMailingList)
>
> id = Int(primary=True)
> accept_these_nonmembers = Pickle() # XXX
>
>
> CREATE TABLE mailinglist (
> id INTEGER NOT NULL,
> accept_these_nonmembers BLOB,
>
>
> mlist.accept_these_nonmembers = []
The Pickle() property type also handles the case of mutable values.
Taking Ryan's sample code, the following would not do what you would
expect, while Barry's version would:
obj.data = []
obj.data.append(42)
There is some overhead in making Pickle() behave correctly for cases
like this (essentially all live objects containing a mutable property
need to be checked for changes on each flush), so there may be some
cases where it makes sense to use something else.
James.
--
storm mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/storm