Hi Max, On 2016-05-01, Max Külshammer <[email protected]> wrote: > I would like to use a sage function (is_power_of) in an cython program I am > writing (via %cython in SMC). To speed things up I would like to import the > c version of is_power_of which can be found > in > https://github.com/sagemath/sage/blob/master/src/sage/rings/integer.pyx#L4271 > as > https://github.com/sagemath/sage/blob/master/src/sage/rings/integer.pxd#L26. > > Can someone explain how I import such an function into cython? My failed > attemps look like this: > > %cython > from libc.math cimport log > cimport integer > from integer cimport _is_power_of
_is_power_of is a method of the extension class "Integer". Hence, when doing from sage.rings.integer cimport Integer and then have something like cdef Integer x = 5 in your code, then you can do x._is_power_of(2) Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
