On Sat, Feb 7, 2009 at 8:02 PM, Robert Bradshaw
<[email protected]> wrote:
> On Feb 7, 2009, at 1:13 PM, Stefan Behnel wrote:
>> Lisandro Dalcin wrote:
>>>
>>> cdef f():
>>> cdef Py_ssize_t a = 5
>>> cdef size_t b = 7
>>> return a + b
>>>
>>> I believe the value of 'a+b' should be promoted to 'signed long
>>> long',
>>
>> Wouldn't Py_ssize_t be a suitable target type? Admittedly, it's <<
>> size_t
>> for non-negative types, but the missing bit shouldn't matter in
>> almost all
>> cases. And if users really need to make use of it, I'm fine with
>> requiring
>> them to write
>>
>> return <PY_LONG_LONG>a + <PY_LONG_LONG>b
>
> Actually, the target should be size_t, following the C standard that
> operations between signed and unsigned have an unsigned result. But
> we certainly shouldn't be promoting it to a new type.
>
Yes, you are right, but then this testcase is expected to fail...
Should we do better?
__doc__ = """
>>> f()
-1
"""
def f():
cdef Py_ssize_t a = -2
cdef size_t b = 1
return a + b
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev