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: >> 1) How are functions depreciated? > > See sage/all.py
Namely message = "\nUsing %(name)s from the top level is deprecated since it was designed to be used by developers rather than end users.\nIt most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in." sage.misc.misc.deprecated_callable_import(None, globals(), locals(), [name for name in globals().keys() if name.startswith('is_') and name[3].isupper()], message) >> Finally 3) What's with all the is_Something(x) functions anyway? As >> far as I can see they always just return isinstance(x, Something). Is >> it because we don't expect a user to know the python isinstance >> function? > > They were from awhile back, but I think it's better to just use > isinstance directly. Yes and no. For example, before Sage had its category framework, one could assume that all rings are instances of sage.rings.ring.Ring and all principal ideal domains are instances of sage.rings.principal_ideal_domain.PrincipalIdealDomain. However, nowadays, for testing whether something is a ring resp. a principal ideal domain, it is really not a good idea to use isinstance. Better do X in Rings() resp. X in PrincipalIdealDomains() Also note that by some recent patch, the recommended way of testing properties is not only better from a mathematical point of view, but it is also **faster** (at least if we are talking about a category without a base ring): (with sage-5.0.beta8) sage: X = QQ['x'] sage: Y = QQ['x','y'] sage: isinstance(X,sage.rings.principal_ideal_domain.PrincipalIdealDomain) True sage: isinstance(Y,sage.rings.principal_ideal_domain.PrincipalIdealDomain) False sage: PID = PrincipalIdealDomains() sage: X in PID True sage: Y in PID False sage: %timeit isinstance(X,sage.rings.principal_ideal_domain.PrincipalIdealDomain) 625 loops, best of 3: 984 ns per loop sage: %timeit X in PID 625 loops, best of 3: 816 ns per loop sage: %timeit isinstance(Y,sage.rings.principal_ideal_domain.PrincipalIdealDomain) 625 loops, best of 3: 1.97 µs per loop sage: %timeit Y in PID 625 loops, best of 3: 1.02 µs per loop If you find an example in sage-5.0 where this gives the wrong answer, then please report! 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