Hi,

please try to avoid top-posting.


Vic Kelson wrote:
> On Mon, Apr 6, 2009 at 12:19 PM, Lisandro Dalcin wrote:
> 
>> I would do this (at de module-level):
>>
>> import math
>> cdef double PI = math.pi
>>
>> of perhaps
>>
>> cdef double PI = 3.14...
>>
>> and just use "PI" on you cdef functions...
>>
> I did the first one. I just wanted to make sure that it was resolved at
> compile time.

Well, not really. The value will be resolved and assigned at *runtime*, or
rather module initialisation time. However, *using* the PI variable in your
code will not involve any Python API calls, as it's a plain C variable.

You can also take the value from math.h (cdef extern from ...), which will
avoid any loss in precision due to the type conversion.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to