#18358: a cython function that produces long given python input
----------------------------+----------------------------------------------
Reporter: | Owner:
vdelecroix | Status: positive_review
Type: | Milestone: sage-duplicate/invalid/wontfix
enhancement | Resolution:
Priority: major | Merged in:
Component: coercion | Reviewers:
Keywords: | Work issues:
Authors: Vincent | Commit:
Delecroix | Stopgaps:
Report Upstream: N/A |
Branch: |
Dependencies: |
----------------------------+----------------------------------------------
Comment (by vdelecroix):
In view of your answer on sage-support, it might still be worth to have
something along
{{{
cdef inline long long_or_LONG_MIN(x):
if PyInt_CheckExact(x):
return PyInt_AS_LONG(x)
elif type(x) is Integer:
if mpz_fits_slong_p((<Integer>x).value):
return mpz_get_si((<Integer>x).value)
else:
return LONG_MIN
else:
try:
return PyNumber_Index(x)
except Exception:
return LONG_MIN
}}}
It would be faster for Python ints and Sage integers.
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/18358#comment:4>
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.