<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<br><br><div><div id="SkyDrivePlaceholder"></div>> From: wesmckinn@gmail.com<br>> Date: Fri, 23 Dec 2011 12:31:45 -0500<br>> To: numpy-discussion@scipy.org<br>> Subject: Re: [Numpy-discussion] PyInt and Numpy's int64 conversion<br>> <br>> On Fri, Dec 23, 2011 at 4:37 AM, xantares 09 <xantares09@hotmail.com> wrote:<br>> > Hi,<br>> ><br>> > I'm using Numpy from the C python api side while tweaking my SWIG interface<br>> > to work with numpy array types.<br>> > I want to convert a numpy array of integers (whose elements are numpy's<br>> > 'int64')<br>> > The problem is that it this int64 type is not compatible with the standard<br>> > python integer type:<br>> > I cannot use PyInt_Check, and PyInt_AsUnsignedLongMask to check and convert<br>> > from int64: basically PyInt_Check returns false.<br>> > I checked the numpy config header and npy_int64 does have a size of 8o,<br>> > which should be the same as int on my x86_64.<br>> > What is the correct way to do that ?<br>> > I checked for a Int64_Check function and didn't find any in numpy headers.<br>> ><br>> > Regards,<br>> ><br>> > x.<br>> ><br>> > _______________________________________________<br>> > NumPy-Discussion mailing list<br>> > NumPy-Discussion@scipy.org<br>> > http://mail.scipy.org/mailman/listinfo/numpy-discussion<br>> ><br>> <br>> hello,<br>> <br>> I think you'll want to use the C macro PyArray_IsIntegerScalar, e.g.<br>> in pandas I have the following function exposed to my Cython code:<br>> <br>> PANDAS_INLINE int<br>> is_integer_object(PyObject* obj) {<br>>   return PyArray_IsIntegerScalar(obj);<br>> }<br>> <br>> last time I checked that macro detects Python int, long, and all of<br>> the NumPy integer hierarchy (int8, 16, 32, 64). If you ONLY want to<br>> check for int64 I am not 100% sure the best way.<br>> <br>> - Wes<br><br>Hi,<br><br>Thank you for your reply !<br><br>That's the thing : I want to check/convert every type of integer, numpy's int64 and also python standard ints.<br>Is there a way to avoid to use only the python api ? ( and avoid to depend on numpy's PyArray_* functions ) <br><br>Regards.<br><br>x.<br><br><br><br><br><br></div>                                        </div></body>
</html>