-
-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cythonize CombinatorialFreeModuleElement #22632
Comments
New commits:
|
Commit: |
comment:3
I Travis, I'm curious, is there any performance gain. I had the impression that storing everything in python dict simply kills all possibilities of optimization ? We discussed during past sage days, to re-implement combinatorial free modules, using arrays with a global dict for all object used only during input and output and not during linear algebra. Florent |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:5
There seems to be a little bit with doing basic operations:
vs old:
While it's not much, it is something like a 10-15% speedup, but it is something likely to be called a significant number of times. It's even more so for scalar multiplication:
vs old:
I might even be able to get some more speed if I am smarter in how we create the results of, e.g., |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:7
That gives a very nice speed boost:
Now those Python calls become relatively expensive, so we should avoid them. |
comment:8
Frédéric, I'm cc-ing you because you might want to note that I am taking care of the |
comment:9
many broken doctests.. |
comment:11
Fixed the pickling issues and the other failures (incompatible signatures for |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
Patchbot is green (essentially, doctest failure is independent). |
comment:14
ping |
comment:15
Plausibly the explanation around that change needs to be updated a bit: there remains no "normal" attribute in this example. Maybe In general, this seems to be calling for changing the running example for this tutorial. The current one is a bit complicated. But that's for a later ticket. |
comment:16
What's the point? |
comment:63
Arg, the exact same I'll set back a positive review when the pdf doc compilation will be finished, in case there wouldbe something else. Thanks Volker for reporting ... |
comment:64
The only other error I get is:
And I assume this is related to an outdate latex install on my machine:
So, putting this back to positive review. Travis, can you double check things compile on your machine? |
comment:66
pdf doc built for me too. |
Changed branch from public/combinat/cythonize_CFM_element-22632 to |
Changed commit from |
comment:68
Question: what exactly is the purpose of the condition involving I am trying to understand how/why (I know it's not directly related to this ticket, but |
comment:69
Hi Jeroen! In |
comment:70
Thanks. That answers the factual question ("how is it done?") but not really the reason. There are many differences between Python and Cython classes and I'm trying to understand which property matters here. I am asking because I tried to always use the dynamic class (using These are the main differences between Python and Cython classes that I can think of:
|
comment:71
Replying to @jdemeyer:
To elaborate on this: after making this change diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx
index a387136..ea7c60c 100644
--- a/src/sage/structure/parent.pyx
+++ b/src/sage/structure/parent.pyx
@@ -571,7 +571,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
# By default, don't fiddle with extension types yet; inheritance from
# categories will probably be achieved in a different way
if inherit is None:
- inherit = not is_extension_type(cls)
+ inherit = True
if inherit:
if name is None:
name = "%s_with_category"%cls.__name__ I ran all doctests in |
comment:72
Hi Jeroen, Thanks for running this interesting experiment! I indeed would have been expecting things not too break too much. Systematically using dynamic classes would certainly simplify Sage's infrastructure. The only potential reason for not doing it is performance (speed and memory footprint). At the time we set this up, there was some consensual claim that systematically using a dynamic class would induce a performance loss for low granularity objects (e.g. finite field elements). Hence the above rule of thumb I implemented for deciding when to do what. However I don't remember anyone doing some serious benchmarking to actually assess the validity of that claim. That would be very welcome! And this hints again at having some speed-regression test infrastructure for Sage. Cheers, PS: I could imagine code breaking in situations like:
where Apparently we have no instance of that idiom in Sage :-) |
comment:73
Comments on this actual ticket: contrary to most element classes which are implemented in Cython, it seems that |
comment:74
In the light of #23435, is it important that
|
comment:75
Another question about this ticket: why are the arithmetic methods of
Every other class (except for This is confusing because
It also prevents a Python class inheriting from |
comment:76
Replying to @jdemeyer:
That is not quite true. They are |
comment:77
Follow-up: #23440 |
comment:78
Replying to @tscrim:
Yes, the |
We move
CombintorialFreeModuleElement
to its own classIndexedFreeModuleElement
and cythonize it for (future) speed gains.CC: @sagetrac-sage-combinat @nthiery @jdemeyer @fchapoton
Component: performance
Keywords: days85
Author: Travis Scrimshaw
Branch:
20cd0da
Reviewer: Nicolas M. Thiéry
Issue created by migration from https://trac.sagemath.org/ticket/22632
The text was updated successfully, but these errors were encountered: