The restrictions are per-subclass so for example you cannot inherit
from both a list and tuple.  The reason here is that list and tuple both
have their own independent layout in memory and there's no relationship
between them.  Or in your case it's set and float.

CompileSubclassTypes takes an arbitrary number of parameters and those
can be either a type (which gets compiled) or they can be a tuple of types
which specify the collection of base types.  The latter form is generally 
useful 
for  including .NET interfaces.

So clr.CompileSubclassTypes("foo", (set, float)) will fail as this is
specifying that you want 1 class which inherits from both set and float. 

But you can do clr.CompileSubclassTypes("foo", set, float) and this specifies
what you want 2 types, one that inherits from set and float.

Or you can do:

clr.CompileSubclassTypes("foo", (set, ), (float, )) 

and again that'll work because it's specifying 2 different base types.


> -----Original Message-----
> From: users-boun...@lists.ironpython.com [mailto:users-
> boun...@lists.ironpython.com] On Behalf Of Tom Wright
> Sent: Tuesday, November 10, 2009 10:08 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] clr.CompileSubclassTypes restrictions on list of
> types
> 
> Thanks the reply,
> 
> Could you clarify slightly what you mean by the Python's normal
> restrictions. I was guessing the restriction might be something like:
> 
> "When compiling a list of types, if the list contains a class B which
> inherits from A then A must be contained in the list."
> 
> The interesting thing here is that the call to CompileSubclassTypes
> works when we pass it one huge list of types, but not when we call if
> repeatedly with smaller lists.
> 
> Thanks
> Tom
> 
> Dino Viehland wrote:
> > The only restrictions are the normal restrictions that Python has regarding
> > inheritance.  In this case it looks like you're hitting that you cannot
> > inherit from more than one base type w/ a different layout.
> >
> > Basically it looks like you're trying to pre-compile the equivalent of:
> >
> > class c(float, set): pass
> >
> > Which isn't legal in Python so my guess is there is an issue w/ the way you
> > split them up.
> >
> >
> >> -----Original Message-----
> >> From: users-boun...@lists.ironpython.com [mailto:users-
> >> boun...@lists.ironpython.com] On Behalf Of Tom Wright
> >> Sent: Tuesday, November 10, 2009 9:39 AM
> >> To: Discussion of IronPython
> >> Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of
> types
> >>
> >> Hi,
> >>
> >> Are there any restrictions placed on the list of types that can be
> >> passed to CompileSubclassTypes?
> >>
> >> We are having issues with a clr.AddReference(DllContainingSubclasses)
> >> being very slow, so are trying to split the compiled subclasses across
> >> multiple dlls to indicate progress between the loading of these dlls.
> >>
> >> However, when trying to compile a partial list of types we get the
> >> following error:
> >>
> >> Traceback (most recent call last):
> >>   File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in
> >> c:\buildsha
> >> re\gitrepo\precompile_subclasses.py
> >> TypeError: : can only extend one CLI or builtin type, not both
> >> Microsoft.Scripti
> >> ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0,
> >> Culture=neutr
> >> al, PublicKeyToken=b77a5c561934e089]] (for
> >> IronPython.Runtime.Types.PythonType)
> >> and IronPython.Runtime.SetCollection (for
> >> IronPython.Runtime.Types.PythonType)
> >>
> >>
> >> Any help is much appreciated,
> >> Tom
> >> _______________________________________________
> >> Users mailing list
> >> Users@lists.ironpython.com
> >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >>
> > _______________________________________________
> > Users mailing list
> > Users@lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> 
> _______________________________________________
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to