#18159: cardinality must output Infinty or a Sage integer
-------------------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: new
Priority: critical | Milestone: sage-6.6
Component: categories | Resolution:
Keywords: | Merged in:
Authors: Vincent Delecroix | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/vdelecroix/18159 | 17924b8da8777805ca17289e00e62c3beca5a146
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by vdelecroix):
Replying to [comment:12 ncohen]:
> I think that it should not be the case because python ints/long are
smaller and faster than Sage Integers, and that we should not be forced to
instantiate Integers if we do not need to.
>
> For the very same reason you invoked, earlier, when you said that you
did not want rationals because of the possible loss of time.
It was not only loss of time but well defineness. Additioning Python int
with Sage integers is slower than Sage integer with Sage integer.
{{{
sage: timeit("sage_a + python_one", number=5000000)
5000000 loops, best of 3: 66.3 ns per loop
sage: timeit("sage_a + sage_one", number=5000000)
5000000 loops, best of 3: 57.9 ns per loop
}}}
So it is better to have everything being Sage integers.
On the other hand, if you really want Python integers you should call
`len(my_set)` (and be sure to obtain a Python integer) and not
`my_set.cardinality()`.
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/18159#comment:15>
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.