Skip to content

use sets instead of lists in the orbit decomposition#41641

Merged
vbraun merged 2 commits intosagemath:developfrom
mantepse:performance/dynamics
Feb 25, 2026
Merged

use sets instead of lists in the orbit decomposition#41641
vbraun merged 2 commits intosagemath:developfrom
mantepse:performance/dynamics

Conversation

@mantepse
Copy link
Copy Markdown
Contributor

@mantepse mantepse commented Feb 13, 2026

Currently, cycles and orbits do the orbit decomposition by picking an element, creating the orbit and then removing newly created elements from the list of all elements.

However, removing an element from a list takes O(n) operations. Turning the list into a set makes some computations possible that would otherwise be quite impossible.

Unfortunately, this means that the (cyclic) ordering of the cycles may change, because we do not control anymore which element is picked first. However, this is only a doctest problem.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 13, 2026

Documentation preview for this PR (built with commit 234da7a; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@dcoudert
Copy link
Copy Markdown
Collaborator

Several doctests must be updated.

Copy link
Copy Markdown
Collaborator

@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 16, 2026
sagemathgh-41641: use sets instead of lists in the orbit decomposition
    
Currently, `cycles` and `orbits` do the orbit decomposition by picking
an element, creating the orbit and then removing newly created elements
from the list of all elements.

However, removing an element from a list takes O(n) operations.  Turning
the list into a set makes some computations possible that would
otherwise be quite impossible.

Unfortunately, this means that the (cyclic) ordering of the cycles may
change, because we do not control anymore which element is picked first.
However, this is only a doctest problem.
    
URL: sagemath#41641
Reported by: Martin Rubey
Reviewer(s): David Coudert
vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 20, 2026
sagemathgh-41641: use sets instead of lists in the orbit decomposition
    
Currently, `cycles` and `orbits` do the orbit decomposition by picking
an element, creating the orbit and then removing newly created elements
from the list of all elements.

However, removing an element from a list takes O(n) operations.  Turning
the list into a set makes some computations possible that would
otherwise be quite impossible.

Unfortunately, this means that the (cyclic) ordering of the cycles may
change, because we do not control anymore which element is picked first.
However, this is only a doctest problem.
    
URL: sagemath#41641
Reported by: Martin Rubey
Reviewer(s): David Coudert
@vbraun vbraun merged commit 08bb0d2 into sagemath:develop Feb 25, 2026
24 checks passed
@mantepse mantepse deleted the performance/dynamics branch February 27, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants