Skip to content

Commit

Permalink
sagemathgh-39469: small improvement in `classically_highest_weight_ve…
Browse files Browse the repository at this point in the history
…ctors`

The change is to avoid insertions and removals at the beginning of a
list as these operations require linear time in the length of the list.
We instead build the reverse path (append and pop at the end of the list
in constant time) and use method `reversed` when needed.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->

URL: sagemath#39469
Reported by: David Coudert
Reviewer(s): Frédéric Chapoton
  • Loading branch information
Release Manager committed Feb 10, 2025
2 parents 28a6b51 + 5c35075 commit 00c302e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=86711d4cbef2cd4e7bb4afcde36965e5dea908e0
sha256=9793cf92ebdceb09050a585294de93c242c033745a0012cae1bd301d307a45df
sha1=2a6cd0b57346c92a73fc14246672abd6f150b423
sha256=a732b3abcdf5f63995c63b765af00bfeed8efb67f1f451caac3ae2f48a105ad4
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
efc0914cd8d72a9bdfdcca4511b55e290b9b6674
3735a1f77361171f19919b1651e14a56332c41ba
9 changes: 5 additions & 4 deletions src/sage/categories/loop_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,16 +773,17 @@ def classically_highest_weight_vectors(self):
except StopIteration:
it.pop()
if path:
path.pop(0)
path.pop()
continue

b = self.element_class(self, [x] + path)
path.append(x)
b = self.element_class(self, reversed(path))
if not b.is_highest_weight(index_set=I0):
path.pop()
continue
path.insert(0, x)
if len(path) == n:
ret.append(b)
path.pop(0)
path.pop()
else:
it.append(iter(self.crystals[-len(path) - 1]))
return tuple(ret)
Expand Down

0 comments on commit 00c302e

Please sign in to comment.