On Friday, December 6, 2013 7:51:35 AM UTC-8, kcrisman wrote:

>
> Just for the record, this wasn't my question :) but hopefully the user 
> accepts it, thanks for this (which in retrospect I should have diagnosed as 
> well, as I have used load/save but thought they were the same as the 
> "usual" pickle).
>
For the most part, dumps(X) amounts to cPickle.dumps(X,protocol=2) and then 
by default further compression. The protocol makes quite a difference in 
the way objects are pickled, though, and a lot of sage implements pickling 
by assuming that protocol==2. I was tripped up by that a couple of times. 
For instance, while it seems from sage's implementation, typing

sage: LaurentPolynomialRing(QQ,'x').__reduce__()

should give a reasonable indication of how it gets pickled, it does not:

sage: LaurentPolynomialRing(QQ,'x').__reduce__()[0]
<function copy_reg._reconstructor>
sage: LaurentPolynomialRing(QQ,'x').__reduce_ex__(2)[0]
<function copy_reg.__newobj__>

The latter is what actually gets executed.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to