source code size metric: Python and modern C++

Brian Quinlan brian at sweetapp.com
Tue Dec 3 18:29:15 EST 2002


> The comment above says it all. Arity means "number of arguments" in
> case you didn't know.  The limit on the number of parameters to a
> function is actually bounded by some internal limit in your compiler,
> which is required to be documented. So in practice, you can only go
> that high.
 
Thanks, I didn't know that. It still sucks though:

add<int, float, int, int, long, int, long, long>(a, b, c, d, e, f, g, h)

Seems less convenient than:

add(a, b, c, d, e, f, g, h)

> You could say that the reason C++ programs are said to be longer than
> Python programs is that the C++ user generally doesn't have the right
> libraries at her disposal (though I have to argue strongly with some
> contentions I've read that things like high-level containers are
> unavailable in C++).  

Is there some way to hack a type-safe container of mixed-types with an
easy to use interface? 

For example, my XML-RPC function could do this:

def things():
	return ['apple', 5, 6.3, {'foo' : 'bar'}, [[[3]]]]

Processing that in XML-RPC C would be very painful. How would you do it?

> Of course, the other side of the coin is that
> the cost of writing the libraries in C++ might be prohibitive.

Which is probably why the only open source C++ XML-RPC library that I
know of doesn't use templates at all.

> There are lots of variations. Here's another:
> 
> ServerProxy.call_method("add", (arg_tuple(5), 5.6, 7, "hello"));

That's disgusting :-)

Cheers,
Brian





More information about the Python-list mailing list