Hi Nicolas!

> >         sage: f._test_pickling()
> >         Traceback (most recent call last):
> >         ...
> >         PicklingError: Can't pickle <type 'function'>: attribute lookup 
> > __builtin__.function failed
> 
> For this one, you can fake ``on_basis'' to be picklable using:
> 
>     sage: import __main__; __main__.on_basis = on_basis

I have been needing to define lots of morphisms using pure functions.

Here's a simple example: try to give every free module an identity morphism
in a way that passes pickling.

{{{

class ModulesWithBasis(Category_over_base_ring):
...
    class ParentMethods:
...
        def _identity_map(self):
            def the_id(x):
                return x
            import __main__; __main__.the_id = the_id
            return SetMorphism(Hom(self,self,self.category()),the_id)

}}}

This isn't going to work if the method is called multiple times
because the global reference will get overwritten.

Solutions?

--Mark

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to