On Wed, Mar 11, 2009 at 5:34 AM, Dag Sverre Seljebotn
<[email protected]> wrote:
> Carl Witty wrote:
>> I just reported http://trac.cython.org/cython_trac/ticket/229, which
>> points out that division and % on cdef ints have C rather than Python
>> semantics (for instance, (-1 % 16) is -1 in C, and 15 in Python).
>>
>> I'm not sure what the right thing to do here is. Using C semantics
>> gives faster code. Using Python semantics is nicer (whenever I care
>> about the difference, I always want Python semantics) but slower, and
>> would be confusing to somebody who was coming from C.
>
> I'm +1 on Python semantics. We could make the C version available under
> some obscure name for any case when one really wants the speed, like
> cython.fast_c_mod(-1, 16).
>
I'm no so sure... C is C, Python is Python, and Cython is in the
middle, but a cdef int is IMHO on C side... Are we going to upcast
'1/2' to a float?
Of course, I could live if Cython does this:
- Python semantics for '%'
- C semantics for an all-new operator '%%'. Just thinking on what
Python has done with '//'
And again... Are we going to upcast '1/2' to a float next?
Still not sure about this...
Dag, some long time ago, when I asked to suport s"abc" string
literals, you told me that such feature is easily implemented on users
side with a tiny function and doing s("abc") ... Well, you were right,
but I believe so I am, users can always implement c = mod(a,b) to
return what they want ;-)
--
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