Mixed types and variants

Diez B. Roggisch deets at nospam.web.de
Wed Nov 23 18:11:12 EST 2005


> If this is not possible, such variants don't look very useful in
> general for SS.
> 
> My possible answers:
> - "Value" types only can be better than nothing, because such variants
> can be used to make mixed dicts, those mixed lists, etc. Some
> functionality reduction is better than an even bigger functionality
> reduction.
> - Maybe the boost::variant sourcecode can be modified to allow such
> functionality too, or part of it. But this may require a LOT of work on
> the C++ implementation (Mark's idea: maybe a better solution would be
> to fall back to CPython classes somehow to implement variants...).
> - Maybe someone here can suggest some other variant type, or some other
> solution.

The problem is that C++ has no means of a dynamic method invocation. So 
I guess the only thing that helps is to use some variant that has a 
PyObject-type, and where calls on values of that type are basically 
translated to python C-Api calls, delegating the execution to python 
itself. Problem: return types aren't known - either handle them as 
PyObjects, or have some cast/hinting in place that reduces them to known 
native types like uniform lists.

my .2ç

Diez



More information about the Python-list mailing list