[C++-SIG] Const-correctness with PythonExtensionBase/PythonExtension<T>

Barry Scott barry at scottb.demon.co.uk
Wed May 17 00:07:03 CEST 2000

You may have a point about the const correctness however I'd
offer this perspective.

If I assume that it is Python calling the methods and Python
has no const awareness the const ness is not used. But it
might usefully prevent people from implementing
non-const algorithms for length() etc.

Adding const versions of add_varargs_method is not useful
as Python will always call the non const version. The const
version is only useful from C++ and these objects are
clumsy to use from C++. Better to add an API useful from C++
directly. (Much like COM Idispatch vs. custom interfaces on

I think the benefit of const algorithms for methods that match
Python semantics that are const is worth doing. But const
add_XXX_methods has no benefits - the add_XXX_methods only
exist to expose methods to Python, Python always calls the
non-const version.


More information about the Cplusplus-sig mailing list