#15820: Implement sequences of bounded integers
--------------------------------------------+------------------------
Reporter: SimonKing | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.3
Component: algebra | Resolution:
Keywords: sequence bounded integer | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
--------------------------------------------+------------------------
Comment (by SimonKing):
Hi Nathann,
Replying to [comment:41 ncohen]:
> HMmmmmm... Does it make any difference ? gcc should resolve those "if"
at compile-time, so if Cython creates two version of the function with an
"if" inside depending on the type, gcc should not include it in the final
binary as the constants involved can be defined at compile-time.
Yes, it is indeed resolved at compile time. Two c-functions are created,
and only the part of the code relevant for the respective code branch
appears in the c-function.
In other words, I now plan to create cdef functions like this:
{{{
#!python
ctypedef seq_t:
first_implementation
second_implementation
cdef seq_t concat(seq_t x, seq_t y):
if seq_t is first_implementation:
<do stuff for 1st implementation>
else:
<do stuff for 2nd implementation>
}}}
and then, in other modules (perhaps also in
`src/sage/combinat/words/word_datatypes.pyx`?), one could uniformly call
`concat(a,b)`, provided that the type of `a` and `b` are known at compile
time (or write `concat[first_implementation](a,b)` explicitly).
I think that such Cython code will be sufficiently nice to read, and the
resulting C-code will be sufficiently fast.
> Anyway, that's a good news ! `:-D`
Indeed!
Simon
--
Ticket URL: <http://trac.sagemath.org/ticket/15820#comment:43>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" 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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.