[sage-devel] Re: Pickling of classes with metaclasses

2011-09-13 Thread Simon King
Hi Nicolas, Florent and Maarten, On 13 Sep., 09:36, "Nicolas M. Thiery" wrote: > On Tue, Sep 13, 2011 at 09:21:45AM +0200, Nicolas M. Thiery wrote: > > What does your FastHashMetaclass do precisely? > > Oops, I had not read the other thread yet ... I just created a ticket for it: #11794. The ne

Re: [sage-devel] Re: Pickling of classes with metaclasses

2011-09-13 Thread Florent Hivert
Hi Nicolas, > What does your FastHashMetaclass do precisely? Could we just throw the > feature in ClasscallMetaclass? This could be a good occasion to find a > more appropriate name for this metaclass. Speaking of which: > ClasscallMetaclass and UniqueRepresentation would deserve to be > cyt

Re: [sage-devel] Re: Pickling of classes with metaclasses

2011-09-13 Thread Nicolas M. Thiery
On Tue, Sep 13, 2011 at 09:21:45AM +0200, Nicolas M. Thiery wrote: > What does your FastHashMetaclass do precisely? Oops, I had not read the other thread yet ... Nicolas -- Nicolas M. ThiƩry "Isil" http://Nicolas.Thiery.name/ -- To post to this group, send an em

Re: [sage-devel] Re: Pickling of classes with metaclasses

2011-09-13 Thread Nicolas M. Thiery
On Sun, Sep 11, 2011 at 04:07:39PM -0700, Simon King wrote: > I found some comments stating that the current use of metaclasses in > Sage is not very scalable. That probably was from me. > I guess that shall be understood as "things get messy if one puts a > new metaclass on top of existing (and

[sage-devel] Re: Pickling of classes with metaclasses

2011-09-11 Thread Simon King
Hi! For the record: If the metaclass M of a new class C is dynamically created, for example from the metaclasses of the bases of C, then pickling of C indeed works after registering copy_reg.pickle(M, M.__reduce__). Remark: I found some comments stating that the current use of metaclasses in Sag

[sage-devel] Re: Pickling of classes with metaclasses

2011-09-11 Thread Simon King
PS: On 11 Sep., 23:01, Simon King wrote: > So, perhaps that is the solution! No, it didn't work. It is the same error. as before. But is it perhaps required that in copy_reg.pickle(metacls, meth), metacls is the exact metaclass of the class to be pickled? In my case, I want to pickle the class

[sage-devel] Re: Pickling of classes with metaclasses

2011-09-11 Thread Simon King
Hi Florent, On 11 Sep., 22:26, Florent Hivert wrote: > I'm not quite sure what's happening but at the end of > the file there is a > > # This registers the appropriate reduction methods (depends on #5985) > import copy_reg > copy_reg.pickle(DynamicMetaclass, DynamicMetaclass.__reduce__) > > impor

Re: [sage-devel] Re: Pickling of classes with metaclasses

2011-09-11 Thread Florent Hivert
Hi Simon, You probably want to have a look at sage/structure/dynamic_class.py which is the file solving those kinds of problems for dynamic classes created by the category system. I'm not quite sure what's happening but at the end of the file there is a # This registers the appropriate redu

[sage-devel] Re: Pickling of classes with metaclasses

2011-09-11 Thread Simon King
Hi Maarten, On 11 Sep., 21:12, Maarten Derickx wrote: > can you check wether type(MyPolyRing).__reduce__() is actually called? It isn't. I am currently trying to understand the "pickle" module. I already found that it there is a special case when type(obj) is a subclass of types.TypeType. That i

[sage-devel] Re: Pickling of classes with metaclasses

2011-09-11 Thread Maarten Derickx
Hmm the only thing I can think of is that .__reduce__ is never called because your metaclass (i.e. type(MyPolyRing)) is a subclass of a class wich implements .__reduce_ex__ can you check wether type(MyPolyRing).__reduce__() is actually called? -- To post to this group, send an email to sage-de