Ticket #5308 (closed enhancement: fixed)
[with patch, positive review] Removing __len__ for combinatorial classes (depend on #5200,#4549)
| Reported by: | hivert | Owned by: | hivert |
|---|---|---|---|
| Priority: | major | Milestone: | sage-3.4.1 |
| Component: | combinatorics | Keywords: | __len__, count, combinatorial class |
| Cc: | sage-combinat | Author(s): | |
| Report Upstream: | Reviewer(s): | ||
| Merged in: | Work issues: |
Description (last modified by hivert) (diff)
After some discussion on sage-combinat-devel, it was decided that __len__ should no be used to get the size of a combinatorial class. Indeed the specifications of __len__ says that it has to return a plain python int, whereas we want to deal with huge and even infinite sets. Unfortunately due to __len__ being called by list / filter / map and maybe some other functions, it is not possible to issue a warning. So it was decided to simply remove it and issue an error, telling to call .cardinality() instead. The former usage of .count() is also deprecated.
Combinat has to be adapted to this and also to the deprecation of iterator in favor of __iter__
I'm preparing a patch to solve those issues.
Cheers,
Florent

