#11943: The category graph should comply with Python's method resolution order
---------------------------+------------------------------------------------
Reporter: SimonKing | Owner: nthiery
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-4.7.3
Component: categories | Keywords: category graph, method resolution
order
Work_issues: | Upstream: N/A
Reviewer: | Author: Simon King
Merged: | Dependencies: #11900
---------------------------+------------------------------------------------
Changes (by SimonKing):
* cc: hivert, mderickx (added)
* status: needs_work => needs_review
* work_issues: Preserve super_categories etc. as methods, but introduce
a lazy attribute _super_categories =>
Comment:
I have changed my patch according to what I learnt from the discussion on
[http://groups.google.com/group/sage-
devel/browse_thread/thread/ab03a0d422810e73 sage-devel]. Namely:
* I preserved the old methods `super_categories` and
`all_super_categories`, so that the users can still work with them and can
read their documentation.
* In particular, if one wants to define a new category, one would still
define a ''method'' (no need for a cached method) called
`super_categories` that returns the immediate super categories. However,
the documentation now also states that internally (i.e., for development),
the new lazy attributes explained below should be used.
* The patch introduces three lazy attributes `_super_categories`,
`_all_super_categories` and `_all_super_categories_proper` that carry the
lists of (immediate or all) super categories. If one asks for the super
categories in code, the fastest way is to request these lazy attributes,
not calling the old methods.
Anyway, why do I see a need to make things faster? Recall that the purpose
of this ticket is to order the list of all super categories according to
Python's method resolution order, i.e., the C3 algorithm. I did my very
best to implement the C3 algorithm as fast as possible. However:
* When I keep super_categories() what they are, then even my best attempt
to implement all_super_categories based on C3 resulted in a mild
regression.
* When I keep super_categories() what they are (namely cached methods)
and use #11115, then there is neither a regression nor a speed-up.
* When I replace super_categories() by _super_categories (a lazy
attribute), then I am getting a speed-up, even without #11115.
Here are the data. I've run `sage -t devel/sage/sage/schemes/` and found
these total running times:
* 620.7 seconds with sage-4.7.3.alpha3
* 600.1 seconds with sage-4.7.3.alpha3 and #11943 (plus dependencies)
That's not much (3.3% speedup), but certainly better than a regression.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11943#comment:12>
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.