[C++-sig] Boost.Python v2: float <==> int, anything ==> str

David Abrahams dave at boost-consulting.com
Tue Sep 3 01:19:58 CEST 2002


As it turns out, I couldn't stand the status quo, so I impulsively changed
the built-in conversion rules in the CVS. The new rules are as follows:

C++ target type       built-in conversions from Python types
---------------       --------------------------------------
signed/unsigned       int,long
char,short,int,long,
long long

float,double,        int,long,float
long double

complex<float>,      int,long,float,complex
complex<double>,
complex<long double>

bool                 int, NoneType (=>false)

std::string          str
char

char const*          str, NoneType (=>NULL)

-------

One thing notably no longer handled automatically is the conversion of
user-defined Python classes to built-in C++ numeric types.

Please let me know if this change causes any upheaval. I've attached a diff
of the Python test files I had to change in order to keep all the tests
passing.

-----------------------------------------------------------
           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs.txt
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20020902/5ab1bc83/attachment.txt>


More information about the Cplusplus-sig mailing list