Re: embedding, getargs/mkvalue asymmetry

Donald Beaudry (don@dvcorp.com)
Wed, 08 Feb 1995 15:12:10 -0500

Mark Lutz wrote:

> For instance:
> int xval, yval, intres, status;
>
> status = run_text("__main__", "(X + Y) > 1000",
> "i", &intres,
> "X", "i", xval, "Y", "i", yval);
>

I haven't needed this exactly, but have done somthing similar. It is
a combination of call_object() and mkvalue(), with it you can simply
say:

res = mkcall_object(callable, "(i(ff))", i, x, y)

rather than creating all those temporary variables that would be
needed otherwise.

I like the idea of extending mkvalue() to use 'O&', 'O!', and 'O?'.
It seems like a natural, though according to Guido's naming
conventions for getargs() (capital letters return Python objects,
lower case return C types), I think 'O&' really needs to be 'o&', but
that is another story.

And speaking of other stories, what I would really like to see is the
'o!' option added to both mkvalue() and getargs(). In other words,

getargs(args, "o!", &Inttype, &i)

would be equivalent to

getargs(args, "i", &i)

Implementing this would be as simple ;) as adding yet another
discipline to the type structure, call it tp_convert. This discipline
would be responsible for converting a Python object to its C
equivalent and from a C type to its Python equivalent. Thus any
built-in type would be able to make itself available for use from
within getargs() and mkvalue().

--
Donald Beaudry                                DataViews Corporation
Software Engineer                             47 Pleasant Street
don@dvcorp.com                                Northampton, MA 01060
		  "So much code, so little time..."