Hello, > wrote: >> Hmm, more cans of worms ... I definitely want the elements of >> IntegerRange(5) to be Sage integers: >> >> sage: IntegerRange(3).an_element().parent() >> Integer Ring >> >> Now the coercion int->Integer is so straightforward that I could be >> convinced to accept int(3) in IntegerRange(5) > > Ah le serpent de mer 'Integer' versus 'int' ! It's very confusing for > the Sage user. Sandpiles where numbers of particles are 'int' > stabilize two times faster than the corresponding ones with 'Integer', > and Sage converts silently a nice constant like 4 to an Integer.
At no point Sage is doing conversion. Sage parser (and then the interpreter) interprets numbers,like 4, as a Sage Integer. It applies also for ".sage" files for which sage interpreter is used. But if you write 4 in a py file then it is a Python int. There is perhaps a reason for lack of speed: a python int is unique but not a Sage integer (try "int(1) is int(1)" verus "Integer(1) is Integer(1)"). In particular, most tests on Python integers as well as allocation are definitely faster. On the other hand, you can not use arbitrary precision numbers nor methods like is_prime. Am I right? Best, Vincent -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.