#11935: Make parent/element classes independent of base rings
-----------------------------------------------------------------+----------
Reporter: SimonKing |
Owner:
Type: enhancement |
Status: needs_review
Priority: major |
Milestone: sage-5.0
Component: categories |
Resolution:
Keywords: parent class, element class, category | Work
issues:
Report Upstream: N/A |
Reviewers:
Authors: Simon King | Merged
in:
Dependencies: #9138, #11900, #11943, #12875, #12876, #12877 |
Stopgaps:
-----------------------------------------------------------------+----------
Comment (by SimonKing):
I still can't reproduce the problem. Too bad. But I have another comment.
With the patch, one has in sage/categories/category.py:
{{{
def _make_named_class(...):
...
else:
# Otherwise, check XXXMethods
import inspect
assert inspect.isclass(method_provider_cls),\
"%s.%s should be a class"%(type(self).__name__,
method_provider)
}}}
That seems suboptimal to me:
{{{
sage: import inspect
sage: def test1(self, cls):
....: import inspect
....: assert inspect.isclass(cls),\
....: "%s.%s should be a class"%(type(self).__name__, repr(cls))
....:
sage: def test2(self, cls):
....: assert inspect.isclass(cls),\
....: "%s.%s should be a class"%(type(self).__name__, repr(cls))
....:
sage: def test3(self, cls):
....: if not inspect.isclass(cls):
....: raise AssertionError, "%s.%s should be a
class"%(type(self).__name__, repr(cls))
....:
sage: test2(ZZ,ZZ.__class__)
sage: %timeit test1(ZZ,ZZ.__class__)
625 loops, best of 3: 4.45 µs per loop
sage: %timeit test2(ZZ,ZZ.__class__)
625 loops, best of 3: 2.67 µs per loop
sage: %timeit test3(ZZ,ZZ.__class__)
625 loops, best of 3: 2.63 µs per loop
}}}
test1 is as in your code: inspect is imported, and (at least it seems to
me) the error message is created even if the error does not occur. test2
does not import inspect again, while test3 is an attempt to not create the
error message.
To my surprise, creating the error message seems to be essentially for
free. But one should really import inspect top-level, I think.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11935#comment:63>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.