On Mon, Jul 26, 2010 at 2:52 AM, Simon King <simon.k...@nuigalway.ie> wrote:
> Nonetheless, Cython needs to know what argument type and type of
> output to expect. Therefore, one has "long lgefint(GEN x)" in the
> Cython header.
>
> It works (at least for me). I admit that it somehow looks wrong, and
> indeed it results in a compiler (or linker?) warning.

This is how it's supposed to work.  You declare the API (not the ABI)
of the external module to Cython, and Cython generates code that uses
that ABI; it doesn't know or care whether the API is implemented as a
function or macro.

What compiler or linker warning do you get?  I just searched through
my install.log (from sage-4.5.2.alpha0), and didn't see anything
relevant when I searched for lgefint or decl.pxi.

> Probably one "clean" way of usage would be to define a proper function
> that wraps the macro. There might be a penalty for calling that
> function, though (or am I mistaken that using a macro is slightly
> faster than using a function of the same content, but results in a
> bigger .so file?).

It depends :)

A macro does duplicate the code everywhere; a function generally does
not, but it might duplicate if the compiler is optimizing aggressively
or if you hint to the compiler that it should do so (by marking the
function "inline").  This may or may not make the code bigger; a
sufficiently simple macro will actually lead to generating less
machine code than a function call, so macros would lead to smaller
code than non-inline functions.  And if code duplication from a macro
does make the code larger, that will quite possibly make it slower as
well, because it will mean less code will fit inside the processor's
instruction cache.

> Cheers,
> Simon

Carl

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to