Closed darijgr closed 9 years ago
Branch pushed to git repo; I updated commit sha1. New commits:
9ce201e | one less to_word |
Branch pushed to git repo; I updated commit sha1. New commits:
fcf411c | last edits |
This is ready for review.
There are minor slowdowns in skew_tableau.py
left, relating to the tuple-cast in its initialization. I don't know if they are avoidable.
Branch pushed to git repo; I updated commit sha1. New commits:
4520047 | put checking into `__init__` and normalization into __classcall_private__ |
Branch pushed to git repo; I updated commit sha1. New commits:
8c19ad3 | so normalizaton is necessary in the init too |
Branch pushed to git repo; I updated commit sha1. New commits:
430003d | actually, probably no need for normalization in __classcall_private__ |
Author: Josh Swanson, Jan Keitel, Darij Grinberg
Changed work issues from see if skew tableaux have gotten slower to none
Description changed:
---
+++
@@ -1,3 +1,22 @@
+Tableaux in Sage used to be implemented as lists of lists. The outer list was wrapped in a `CombinatorialObject`, which made it immutable (at least without accessing underscored attributes). The inner lists, however, could be easily mutated; for example:
+
+```
+sage: T = Tableau([[1,2],[2]])
+sage: t0 = T[0]
+sage: t0[1] = 3
+sage: T
+[[1, 3], [2]]
+```
+This kind of mutability was likely not intended. I, personally, have only ever triggered it by accident.
+
+The present branch replaces the inner lists in the implementation of tableaux and skew tableaux by tuples. As a consequence, tableaux become completely (rather than just shallowly) immutable (unless their entries themselves are mutable, which can be blamed on the user). They are still printed as lists of lists, but this is just a `_repr_` issue.
+
+The branch also makes some optimizations and corrections.
+
+---
+
+Old description:
+
Tableaux in Sage are mutable objects, at least indirectly:
Reviewer: Travis Scrimshaw
LGTM.
Thank you, Travis!
Changed branch from public/15862 to 430003d
Tableaux in Sage used to be implemented as lists of lists. The outer list was wrapped in a
CombinatorialObject
, which made it immutable (at least without accessing underscored attributes). The inner lists, however, could be easily mutated; for example:This kind of mutability was likely not intended. I, personally, have only ever triggered it by accident.
The present branch replaces the inner lists in the implementation of tableaux and skew tableaux by tuples. As a consequence, tableaux become completely (rather than just shallowly) immutable (unless their entries themselves are mutable, which can be blamed on the user). They are still printed as lists of lists, but this is just a
_repr_
issue.The branch also makes some optimizations and corrections.
Old description:
Tableaux in Sage are mutable objects, at least indirectly:
This in itself is probably not a bug, although not the kind of behavior I like either (what exactly is sped up by mutability of tableaux?). But there are things which probably are bugs given this behavior:
sage/combinat/tableau.py
says:But we are not immutable. This comment line is supposed to provide justification for initializing the tableau as a
CombinatorialObject
, but the docstring ofCombinatorialObject
says that "CombinatorialObjects are shallowly immutable, and the intention is that they are semantically immutable". The latter is not satisfied for tableaux.If we want tableaux to be mutable, why wrap them inside such a class? If we want them to be immutable, wouldn't it be right to encode them as CombinatorialObjects of CombinatorialObjects? Or is the speed cost for this too steep? And, finally, what is it that CombinatorialObject does that tuple does not?
And, on a related note, does Sage provide a class for immutable dictionaries? (I'm still hell-bent on implementing arbitrary-shaped tableaux.)
CC: @anneschilling @tscrim @nthiery @stumpc5 @AndrewAtLarge @zabrocki @sagetrac-sage-combinat @hivert @sagetrac-jpswanson
Component: combinatorics
Keywords: tableaux, sage-combinat, mutability, days64
Stopgaps: #17997
Author: Josh Swanson, Jan Keitel, Darij Grinberg
Branch/Commit:
430003d
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/15862