Hi! On 2012-03-26, Mike Hansen <mhan...@gmail.com> wrote: > On Sun, Mar 25, 2012 at 11:06 PM, Starx <jst...@gmail.com> wrote: > See sage/all.py -- they are only deprecated from Sage's "global > namespace" in order to avoid users seeing things like > > sage: is_Integer(int(2)) > False
Since I talked about timings in my previous post... The "correct" way of testing whether something is an integer is clearly slower than the deprecated way, but I think it is still acceptable: sage: from sage.rings.integer import is_Integer sage: n = 5 sage: %timeit is_Integer(5) sage: %timeit is_Integer(n) 625 loops, best of 3: 198 ns per loop sage: %timeit n in ZZ 625 loops, best of 3: 283 ns per loop Note that the deprecation warning explicitly states that you are likely to get "unexpected" results when using this function (namely, when you expect that the behaviour of this function has a mathematical meaning), and here you are: sage: is_Integer(int(5)) False sage: is_Integer(5/1) False sage: int(5) in ZZ True sage: 5/1 in ZZ True So, if you want to know whether something is (equal to) an integer, regardless of the type, then "x in ZZ" is the way to go, even though it is slower. Cheers, Simon -- 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