[C++-sig] boost.python and numpy.int32 on 64-bit system

Andreas Klöckner lists at informa.tiker.net
Thu Apr 17 14:52:04 CEST 2008

On Donnerstag 17 April 2008, Ger van Diepen wrote:
>   ArgumentError: Python argument types in
>     Table.getcell(table, str, numpy.int32)
>   did not match C++ signature:
>     getcell(casa::TableProxy {lvalue}, std::string columnname, int rownr)

This is numpy's fault, as it returns what they term an 'array scalar'. This is 
because Python's "int" on a 64-bit machine is 64 bits:

>>> 2**39
>>> 2**66

(see when the "L" shows up)

But numpy wants to return the exact data type you have in your array, so it 
gives you something that's not an int. As BP doesn't know about numpy by 
default (and can't assume it's there), there's no support. You would need to 
install custom (from-/to-python) rvalue converters for numpy's array scalars. 
I have something in the works that might help you--watch for an announcement 
in the next few days. But for now the explicit conversion hack is probably 
your easiest route to success.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080417/7b30e2bc/attachment.pgp>

More information about the Cplusplus-sig mailing list